2

I want to rewrite

www.example.com/story.php?id=123&title=abc&cat=sports

to

www.example.com/story/123?title=abc&cat=sports

and i have used

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^\.]+)$ $1.php [NC,L]

its not working.

1 Answer 1

1
RewriteEngine On
RewriteCond %{THE_REQUEST} ^GET\ /(story)\.php\?id=(\d+)&(\S+) [NC]
RewriteRule ^story\.php$ /%1/%2?%3 [R=301,L]

RewriteRule ^(story)/(\d+)/?$ /$1.php?id=$2 [L,QSA]

The above rules should work as needed.

Sign up to request clarification or add additional context in comments.

6 Comments

i tried this but it shows " The requested URL /story.php was not found on this server." and i have tested this in "htaccess.madewithlove.be" it shows error "RewriteCond %{THE_REQUEST} ^GET\ /(story)\.php\?id=(\d+)&(\S+) [NC] This variable is not supported: %{THE_REQUEST}". please help.
@ghost Provide the directory structure. Where is the story.php file located? Where are you putting the htaccess file ?
both htaccess and story.php are in root directory.
@ghost if the error shown is "The requested URL /story.php was not found on this server", then at least story.php is not in the root directory.
page is there . can u check htaccess in htaccess.madewithlove.be . it shows "RewriteCond %{THE_REQUEST} ^GET\ /(story)\.php\?id=(\d+)&(\S+) [NC] This variable is not supported: %{THE_REQUEST}"
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.