Question

How do you forward a directory with a question mark in it?

I'm trying to use htaccess to forward all requests, however the URL I need to forward has a question mark in it and for the life of me, I have tried everything but cannot get anything to work because of that question mark.

I'm trying to forward this:

http://domain.com/index.php?/

To this:

http://domain.com/

What can I put in my htaccess to do this?

The goal is so that old references to this URL will automatically forward to the new URL structure. Example:

Old URL Structure

http://domain.com/index.php?/topic/

New URL Structure:

http://domain.com/topic/

Any help would be greatly appreciated.

Thanks in advance.

Was it helpful?

Solution

Put this code in your DOCUMENT_ROOT/.htaccess file:

RewriteEngine On

RewriteCond %{THE_REQUEST} \s/+index\.php\?(/\S+) [NC]
RewriteRule ^ /%1? [R=301,L]
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top