htaccess redirect

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • RuthC
    New Member
    • Nov 2007
    • 33

    htaccess redirect

    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
    [CODE=apache]
    RewriteRule ^mypage/(.*)/ mypage.php?u=$1
    [/CODE]
    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.

    [CODE=apache]
    AddType application/x-httpd-php .aspx
    ErrorDocument 404 /404.php
    RewriteEngine on

    RewriteRule ^privacy_policy/ privacy_policy. php
    RewriteRule ^antispam_polic y/ antispam_policy .php
    RewriteRule ^terms_of_use/ terms_of_use.ph p
    RewriteRule ^about_us/ about_us.php
    RewriteRule ^press/ press.php
    RewriteRule ^shop/ shop.php
    RewriteRule ^sitemap/ sitemap.php
    RewriteRule ^help/ help.php
    RewriteRule ^faq/ faq.php
    RewriteRule ^search/ search.php
    RewriteRule ^login/password login.php?pw=lo stpw
    RewriteRule ^login/ login.php?c=log in
    RewriteRule ^memberPages/page([0-9])/ memberPages.php ?one2=$1
    RewriteRule ^member/favourites/([0-9]+)/ secure/favourites.php? p=$1
    RewriteRule ^member/favourites/SH([^/\.]+)/?$ secure/favourites.php? d=$1
    RewriteRule ^member/reminders/E([^/\.]+)/?$ secure/reminders.php?c =edit&rid=$1 [L]
    RewriteRule ^member/reminders/D([^/\.]+)/?$ secure/reminders.php?c =delete&rid=$1 [L]
    RewriteRule ^member/refer/(.+)/ secure/refer.php?refer rer=$1
    RewriteRule ^charity/CH([0-9]+)/ charity.php?ch= $1
    RewriteRule ^charity/(.*)/ charity.php?cat egory=$1
    RewriteRule ^charity/ charity.php
    RewriteRule ^member/donation/([0-9]+)/ secure/donation.php?ci d=$1
    RewriteRule ^member/donation/ secure/donation.php

    RewriteCond %{REQUEST_URI} !=/member/myaccount/
    RewriteCond %{REQUEST_URI} !=/member/profile/
    RewriteCond %{REQUEST_URI} !=/member/profile/Password/
    RewriteCond %{REQUEST_URI} !=/member/refer_and_earn/
    RewriteCond %{REQUEST_URI} !=/member/favourites/
    RewriteCond %{REQUEST_URI} !=/member/favourites/([0-9]+)
    RewriteCond %{REQUEST_URI} !=/member/favourites/SH([^/\.]+)/?$
    RewriteCond %{REQUEST_URI} !=/member/reminders/
    RewriteCond %{REQUEST_URI} !=/member/create_mypage/
    RewriteCond %{REQUEST_URI} !=/member/manage_mypage/
    RewriteCond %{REQUEST_URI} !=/member/edit_mypage/
    RewriteCond %{REQUEST_URI} !=/member/reminders/(.*)
    RewriteCond %{REQUEST_URI} !=/member/refer/(.*)
    RewriteRule ^member/(.+)/ secure/login.php?c=$1

    RewriteRule ^member/myaccount/ secure/myaccount.php
    RewriteRule ^member/refer_and_earn/ secure/refer_and_earn. php

    RewriteCond %{REQUEST_URI} !=/member/reminders/(.*)
    RewriteRule ^member/reminders/ secure/reminders.php

    RewriteCond %{REQUEST_URI} !=/member/favourites/(.*)
    RewriteRule ^member/favourites/ secure/favourites.php

    RewriteRule ^member/create_mypage/ secure/create_mypage.p hp
    RewriteRule ^member/manage_mypage/ secure/manage_mypage.p hp
    RewriteRule ^member/edit_mypage/ secure/manage_mypage.p hp?c=edit

    RewriteCond %{REQUEST_URI} !=/member/profile/Password/
    RewriteRule ^member/profile/ secure/profile.php

    RewriteRule ^member/profile/(.+)/ secure/profile.php?c=$ 1
    RewriteCond %{REQUEST_URI} !=/member/profile/Password/

    RewriteCond %{REQUEST_URI} !=/memberPages/page([0-9])/
    RewriteRule ^memberPages/ memberPages.php

    RewriteRule ^all(.*)/ show_all_retail ers.php?p=$1
    RewriteRule ^rev(.*)/ query.php?revie w=$1
    RewriteRule ^UK(.*)/ offer.php?id=$1
    #RewriteRule ^mypage/(.*)/ mypage.php?u=$1

    RewriteCond %{REQUEST_URI} \-
    RewriteCond %{REQUEST_URI} !^/Link_Images/(.*)
    RewriteCond %{REQUEST_URI} !^/images/(.*)
    RewriteRule ^(.*)$ query.php?q=$1

    RewriteCond %{HTTPS} !=on
    RewriteRule ^member/(.*) https://%{HTTP_HOST}/secure$1 [L]

    [/CODE]
    Last edited by pbmods; Nov 26 '07, 06:49 PM. Reason: Fixed CODE tags.
  • pbmods
    Recognized Expert Expert
    • Apr 2007
    • 5821

    #2
    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:
    [code=apache]
    RewriteRule ^mypage/([^/]+)/? mypage.php?u=$1
    [/code]

    is a tad bit faster than this:
    [code=apache]
    RewriteRule ^mypage/(.*)/ mypage.php?u=$1
    [/code]

    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.

    Comment

    • Markus
      Recognized Expert Expert
      • Jun 2007
      • 6092

      #3
      I think he wants



      to be recognised as this



      So he can run $_GET to retrieve the username

      but he also wants the url to remain as



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

      [code=apache]
      RewriteRule ^users/([\w])$ users/?u=$1 [L]
      [/code]
      the [L] is what keeps the url as it is entered. :)

      Comment

      Working...