1

I have an old URL syntax and since I changed my CMS, the old syntax doesn't work anymore and I have a lot of error 404. I want to delete "article.php?p=" here :

to :

How can I totally remove the string "article.php?p=" from my URLs with htaccess please ? I tried a lot of things but it seems too difficult for me.

2 Answers 2

1

To remove article.php?p= use the following:

RewriteEngine On
RewriteRule ^([^/]*)\.php$ /article.php?p=$1 [L]

You can use this as an alternative:

RewriteCond %{QUERY_STRING} (^|&)p=name_of_my_page($|&)
RewriteRule ^article\.php$ /name_of_my_page?&%{QUERY_STRING}
Sign up to request clarification or add additional context in comments.

Comments

1

To redirect the old URL to the new one, you must first capture the page's name from the query string with RewriteCond and then use this in RewriteRule

RewriteCond &%{QUERY_STRING}& &p=(.*?)&
RewriteRule ^article\.php$ /%1? [R,L]

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.