473,725 Members | 2,232 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

htaccess redirect

33 New Member
Hi, In my website there is a facility for user to create there own pages
we are maintaing this url as
www.mywebsite.com/mypage/user created page name
ex : www.mywebsite.com/mypage/ruth
user created page name can contain alphanumeric charecters including '_' (no white space)

I am using this code to redirect the user created pages
Expand|Select|Wrap|Line Numbers
  1. RewriteRule  ^mypage/(.*)/  mypage.php?u=$1
  2.  
Now I am in a trouble boz I want to maintain my user created page url like
www.mywebsite.com/user created page name
ex: www.mywebsite.com/ruth
please help me to find the solution

Here is my .htaccess file.

Expand|Select|Wrap|Line Numbers
  1. AddType application/x-httpd-php .aspx
  2. ErrorDocument 404 /404.php
  3. RewriteEngine on
  4.  
  5. RewriteRule ^privacy_policy/ privacy_policy.php
  6. RewriteRule ^antispam_policy/ antispam_policy.php
  7. RewriteRule ^terms_of_use/ terms_of_use.php
  8. RewriteRule ^about_us/ about_us.php
  9. RewriteRule ^press/ press.php
  10. RewriteRule ^shop/ shop.php
  11. RewriteRule ^sitemap/ sitemap.php
  12. RewriteRule ^help/ help.php
  13. RewriteRule ^faq/ faq.php
  14. RewriteRule ^search/ search.php
  15. RewriteRule ^login/password login.php?pw=lostpw
  16. RewriteRule ^login/ login.php?c=login
  17. RewriteRule ^memberPages/page([0-9])/ memberPages.php?one2=$1
  18. RewriteRule ^member/favourites/([0-9]+)/ secure/favourites.php?p=$1
  19. RewriteRule ^member/favourites/SH([^/\.]+)/?$ secure/favourites.php?d=$1
  20. RewriteRule ^member/reminders/E([^/\.]+)/?$ secure/reminders.php?c=edit&rid=$1 [L]
  21. RewriteRule ^member/reminders/D([^/\.]+)/?$ secure/reminders.php?c=delete&rid=$1 [L]
  22. RewriteRule ^member/refer/(.+)/ secure/refer.php?referrer=$1
  23. RewriteRule ^charity/CH([0-9]+)/ charity.php?ch=$1
  24. RewriteRule ^charity/(.*)/ charity.php?category=$1
  25. RewriteRule ^charity/ charity.php
  26. RewriteRule ^member/donation/([0-9]+)/ secure/donation.php?cid=$1
  27. RewriteRule ^member/donation/ secure/donation.php
  28.  
  29. RewriteCond %{REQUEST_URI} !=/member/myaccount/
  30. RewriteCond %{REQUEST_URI} !=/member/profile/
  31. RewriteCond %{REQUEST_URI} !=/member/profile/Password/
  32. RewriteCond %{REQUEST_URI} !=/member/refer_and_earn/
  33. RewriteCond %{REQUEST_URI} !=/member/favourites/
  34. RewriteCond %{REQUEST_URI} !=/member/favourites/([0-9]+)
  35. RewriteCond %{REQUEST_URI} !=/member/favourites/SH([^/\.]+)/?$ 
  36. RewriteCond %{REQUEST_URI} !=/member/reminders/
  37. RewriteCond %{REQUEST_URI} !=/member/create_mypage/
  38. RewriteCond %{REQUEST_URI} !=/member/manage_mypage/
  39. RewriteCond %{REQUEST_URI} !=/member/edit_mypage/
  40. RewriteCond %{REQUEST_URI} !=/member/reminders/(.*)
  41. RewriteCond %{REQUEST_URI} !=/member/refer/(.*)
  42. RewriteRule ^member/(.+)/ secure/login.php?c=$1
  43.  
  44. RewriteRule ^member/myaccount/ secure/myaccount.php
  45. RewriteRule ^member/refer_and_earn/ secure/refer_and_earn.php
  46.  
  47. RewriteCond %{REQUEST_URI} !=/member/reminders/(.*)
  48. RewriteRule ^member/reminders/ secure/reminders.php
  49.  
  50. RewriteCond %{REQUEST_URI} !=/member/favourites/(.*)
  51. RewriteRule ^member/favourites/ secure/favourites.php
  52.  
  53. RewriteRule ^member/create_mypage/ secure/create_mypage.php
  54. RewriteRule ^member/manage_mypage/ secure/manage_mypage.php
  55. RewriteRule ^member/edit_mypage/ secure/manage_mypage.php?c=edit
  56.  
  57. RewriteCond %{REQUEST_URI} !=/member/profile/Password/
  58. RewriteRule ^member/profile/ secure/profile.php
  59.  
  60. RewriteRule ^member/profile/(.+)/ secure/profile.php?c=$1
  61. RewriteCond %{REQUEST_URI} !=/member/profile/Password/
  62.  
  63. RewriteCond %{REQUEST_URI} !=/memberPages/page([0-9])/
  64. RewriteRule ^memberPages/ memberPages.php
  65.  
  66. RewriteRule ^all(.*)/ show_all_retailers.php?p=$1
  67. RewriteRule ^rev(.*)/ query.php?review=$1
  68. RewriteRule  ^UK(.*)/  offer.php?id=$1
  69. #RewriteRule  ^mypage/(.*)/  mypage.php?u=$1
  70.  
  71. RewriteCond %{REQUEST_URI} \-
  72. RewriteCond %{REQUEST_URI} !^/Link_Images/(.*)
  73. RewriteCond %{REQUEST_URI} !^/images/(.*)
  74. RewriteRule ^(.*)$ query.php?q=$1
  75.  
  76. RewriteCond %{HTTPS} !=on
  77. RewriteRule ^member/(.*) https://%{HTTP_HOST}/secure$1 [L]
  78.  
  79.  
Nov 21 '07 #1
2 3742
pbmods
5,821 Recognized Expert Expert
Heya, Ruth.

What do you want your code to do? Give an example.
What is your code doing that you don't want it to do? Give an example.
What is your code *not* doing that it is supposed to? Give an example.

Incidentally, this:
Expand|Select|Wrap|Line Numbers
  1. RewriteRule  ^mypage/([^/]+)/?  mypage.php?u=$1
  2.  
is a tad bit faster than this:
Expand|Select|Wrap|Line Numbers
  1. RewriteRule  ^mypage/(.*)/  mypage.php?u=$1
  2.  
because it will stop as soon as it hits a '/' character rather than continue matching to the end of the string.

I also made the trailing '/' optional, since that's the behavior that Users would expect to see with 'normal' URLs.
Nov 26 '07 #2
Markus
6,050 Recognized Expert Expert
I think he wants

www.mysite.com/users/userpage

to be recognised as this

www.mysite.com/users/?u=userpage

So he can run $_GET to retrieve the username

but he also wants the url to remain as

www.mysite.com/users/userpage

I recently asked about this - what you've got is absolutely spot on you just need to add one little bit! :

Expand|Select|Wrap|Line Numbers
  1. RewriteRule ^users/([\w])$ users/?u=$1 [L]
  2.  
the [L] is what keeps the url as it is entered. :)
Nov 26 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

7
3687
by: Nel | last post by:
Just looking for some general advice on modifying the URL for php. I am using .htaccess to allow a web site to translate example.html to index.php?content=example (below) ErrorDocument 404 http://www.example.com RewriteEngine on RewriteRule ^/?(.*).html$ /index.php?content=$1
1
2688
by: deko | last post by:
Can I use PHP and htaccess to authenticate users? My service provider lets me password protect directories on my web site - using htaccess. If a user tries to access a page within a password protected directory, a dialog is received requesting username and password. But I want to provide a login page that users go to first, and then are directed to the page/directory that they are allowed to see based on their username/password. Is...
9
37737
by: deko | last post by:
I want to use htaccess for authentication on my php site since I only have a few users who need access to secure areas. So, I created a new directory off public_html (secretDocs) and in that directory there is a .htaccess file that looks like this: AuthType Basic AuthName "someuser" AuthUserFile "/home/mydirectory/.htpasswds/secretDocs/passwd" require valid-user
15
5144
by: Taki Jeden | last post by:
Hello everybody Does anybody know why w3c validator can not get pages that use 404 htaccess redirection? I set up two web sites so that clients request non-existent urls, but htaccess redirects calls to a script which parses the url and produces requested pages. It works fine with browsers, but when I try to validate the page I get a 404 error - which bewilders me, because I thought Apache does the redirection internally without sending...
3
2128
by: Vardan Kushnir | last post by:
Please forgive me if my English is poor. Also please tell me if this is wrong place to ask this question and tell me better place. When searching web for information Re: .htaccess and redirecting, I see many different examples of methods. I wish to be able to say "this is good method that I can always use" even if exists other good methods. I wish not be confused by many different examples of methods.
5
1534
by: tommytx | last post by:
Is there any capability of decisions in htaccess. I know you can use in special situations, but I need something like: If a then b etc like in php. In other words I want to redirect the visitor to one of many pages via the htaccess file. Is there anyway to open a file and have a redirect to a different web page based on an input from a text file as below:
5
4997
by: deko | last post by:
I'm trying to redirect requests for /index.php to /mydirectory/index.php If I use an index file in / with only this line: <?php header("Location:http://www.mysite.com/mydirectory/"); ?> that seems to work. But can this be accomplished more efficiently with an htaccess rewrite?
0
2093
by: Stuart Palmer | last post by:
Hi everyone, I'm trying to look for an asp equivilent of .htaccess that is used on apache servers but for use with asp. I am doing a website and moving lots of files into a single directory to make it easier to maintain, however, I don't want to loose the search engine indexing that is already in place. What I would like to have is a db/.htacces-like files, that when a page doesn't exist the server redirect.
2
1784
by: RuthC | last post by:
Hi. I am using .htaccess to redirect in my website Now I want to redirect a url, which Contain '-' to another url. ex: RewriteRule ^book-and-magazine-discount/ query.php?q=$1.
1
3642
by: Lagon666 | last post by:
Hi I wanna have a htaccess file that when i go to "www.domain.com/sometext" the page redirect to "www.domain.com/user.php?user=sometext". It's important that is better that URL not end with slash. I have a problem with my htaccess file: RewriteEngine on RewriteRule ^(.+)$ user.php?user=$1 But when i go to to "http://localhost/jack" the page will redirect to "http://localhost/user.php?user=user.php". I have read this topic, but is...
0
8888
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8752
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9401
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9113
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6702
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6011
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4519
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4784
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2157
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.