skip to Main Content

I am trying to redirect the page from mysite.com/page1?id=37773 to mysite.com/page1/37773.

I tried seraching on various blogs where i found them trying with php files but even when i copied and rewrite it wont work so i am here to get help of exprets .Thanks in advance.

what i have tried so far

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}.html -f
RewriteRule ^(.*)$ $1.html [NC,L]
RewriteRule ^page1/([a-zA-Z_-]+).html$ page?id=$1

2

Answers


  1. Chosen as BEST ANSWER

    what i did:-

    RewriteEngine ON
    RewriteRule ^file/([^/]+) $file.html?id=$1 [L,QSA] #displays mysite.com/file/29829 on browser while the request would be mysite.com/file?id=29829
    
    
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME}.html -f
    RewriteRule ^(.*)$ $1.html [NC,L]
    

  2. You can try this :

    RewriteEngine ON
    ##External redirect rules here.
    RewriteCond %{THE_REQUEST} mysite/page1?id=(S+)s
    RewriteRule ^ mysite/page1/%1? [R=301,L]
    
    ##Internal rewrite rules here...
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^mysite/page1/([^/]+)/?$  mysite/page1?id=$1 [NC,QSA,L]
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search