473,399 Members | 4,192 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 software developers and data experts.

htaccess redirect

33
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 3731
pbmods
5,821 Expert 4TB
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 Expert 4TB
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
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...
1
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...
9
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...
15
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...
3
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...
5
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...
5
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...
0
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...
2
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
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....
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
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...

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.