1

I am on a Apache server and have created a site with php using a MySQL database on IONOS.

I want to redirect the URLs from /page.php?id=xxx to /page/xxx

I have written a .htaccess file and uploaded it into the root folder. It worked fine until yesterday. I have looked all IONOS support pages and different websites, but I can't find what's the issue.

My htaccess file looks like this:

RewriteEngine On

RewriteBase /

RewriteRule ^page/(.*)$ page.php?id=$1 [QSA,L]

When I try to access the page with /page/xxx, it can't get the xxx id variable.

Zuzen
  • 23
  • 4
  • Looks like `Multiviews` are enabled on your server. Try adding this line `Options -Multiviews` to your htaccess to disable the directive then you will be able to use the `RewriteRule` – Amit Verma Dec 22 '20 at 07:02
  • Thank you Amit. Indeed, I needed this instruction! – Zuzen Dec 22 '20 at 17:37

1 Answers1

0

RewriteBase / is not required in DocumentRoot. Also, your RewriteRule appears to be reversed:

RewriteRule ^page\.php?id=(.*)$ /page/$1 [QSA,L]
Allan Wind
  • 23,068
  • 5
  • 28
  • 38
  • leading slash in `RewriteRule`'s pattern is not required when used in htaccess context. It should be removed otherwise the rule wont match the request. . `RewriteBase` is required because OP is using a relative path as substitution string. Plus you cant match against query string in RewriteRule You need to match against `%{QUERY_STRING}` – Amit Verma Dec 22 '20 at 06:52
  • It still won't work. Op doesn't want to reditect the old URL to the new one. OP wants to map new URL to the old location. – Amit Verma Dec 22 '20 at 07:11