1

I want to rewrite my URL:

http://jainpopulationregister.com/page.php?action=about

to:

http://jainpopulationregister.com/page/action/about/

with URL rewriting

My current URL rewrite code is as follows:

Options +FollowSymLinks
RewriteEngine on
RewriteRule page/action/(.*)/ page.php?action=$1
RewriteRule page/action/(.*) page.php?action=$1 

But when I place this in my root folder, nothing seems to happen. What am I doing wrong?

1
  • you are probably missing RewriteBase / and rule like RewriteRule ^page/action/(.*)/$ /page.php?action=$1 [L,QSA] Commented May 1, 2014 at 9:14

2 Answers 2

1

You want to redirect from
http://jainpopulationregister.com/page.php?action=about
to
http://jainpopulationregister.com/page/action/about/

but your redirect rule does exactly the opposite. Assuming that you really want to redirect from /page.php?action=about to /page/action/about/, use the following configuration in htaccess:

Options +FollowSymLinks
RewriteEngine on
RewriteCond %{QUERY_STRING} ^action=(.*)$ 
RewriteRule ^(.*)$ /page/action/%1/? [R=302,L]
Sign up to request clarification or add additional context in comments.

Comments

0
RewriteRule ^page/action/([a-zA-Z0-9]+)/$ pages.php?action=$1 [NC,L]

In "pages.php" file get the action $_GET['action'];

Comments

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.