URL Rewriting in a PHP Website .htaccess

Discussion in 'PHP' started by webmaster365, Feb 12, 2011.

  1. #1
    webmaster365, Feb 12, 2011 IP
  2. MyVodaFone

    MyVodaFone Well-Known Member

    Messages:
    1,048
    Likes Received:
    42
    Best Answers:
    10
    Trophy Points:
    195
    #2

    Not tested of course but it should redirect to "newfolder/randomvalue1/randomvalue2" Which are variables $2 & $3
    
    Options +FollowSymLinks
    
    RewriteEngine on
    
    RewriteBase /
    
    RewriteRule ^newfolder/([^/]+)/([^/]+)/([^/]+)\?$ newfolder/$1/$2/$3 [L]
    
    RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /newfolder/([^&]+)/([^&]+)/([^&]+)\ HTTP/
    
    RewriteRule ^index\.php$ /newfolder/%2/%3? [R=301,L]
    
    PHP:
     
    MyVodaFone, Feb 12, 2011 IP
  3. mastermunj

    mastermunj Well-Known Member

    Messages:
    687
    Likes Received:
    13
    Best Answers:
    0
    Trophy Points:
    110
    #3
    Hi webmaster365,
    The first url seems to have been created using rewrite rule itself, is it the case? If so, making little modification in the same rule will give you desired result.
     
    mastermunj, Feb 12, 2011 IP
  4. webmaster365

    webmaster365 Greenhorn

    Messages:
    86
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    16
    #4
    Can you please tell me what is the change.

    As my code like below.

    Options +FollowSymLinks All
    Options -MultiViews All
    RewriteEngine on
    RewriteCond %{HTTP_HOST} ^domain.com [NC]
    RewriteRule ^(.*)$ http://www.domain.com/movies/$1 [L,R=301]
    RewriteCond %{HTTP_REFERER} !^$
    RewriteCond %{HTTP_REFERER} !^http://(www\.)?domain.com/.*$ [NC]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d

    RewriteRule ^overview/(.*)/(.*)$ overview.php?mv=$1&id=$2 [L]


    So, the above URL i want to change. i need to remove the overview part as this is page name.

    Thanks

     
    webmaster365, Feb 13, 2011 IP
  5. mastermunj

    mastermunj Well-Known Member

    Messages:
    687
    Likes Received:
    13
    Best Answers:
    0
    Trophy Points:
    110
    #5
    Is overview an actual directory?

    If not, changing

    
    RewriteRule ^overview/(.*)/(.*)$ overview.php?mv=$1&id=$2 [L]
    
    Code (markup):
    INTO

    
    RewriteRule ^(.*)/(.*)$ overview.php?mv=$1&id=$2 [L]
    
    Code (markup):
    should help.

    Can you share original URLs with us? That would give us much better idea on what has to be done.



     
    Last edited: Feb 13, 2011
    mastermunj, Feb 13, 2011 IP
  6. webmaster365

    webmaster365 Greenhorn

    Messages:
    86
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    16
    #6
    The URL is : -
    www.fridayrelease.com/movies/overview/patang/9945
    the overview is page name not folder name

    Thanks for your valuable time.
     
    webmaster365, Feb 14, 2011 IP
  7. mastermunj

    mastermunj Well-Known Member

    Messages:
    687
    Likes Received:
    13
    Best Answers:
    0
    Trophy Points:
    110
    #7
    Did you try the changes I suggested on development setup?
     
    mastermunj, Feb 14, 2011 IP