문제

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.

도움이 되었습니까?

해결책

Put this code in your DOCUMENT_ROOT/.htaccess file:

RewriteEngine On

RewriteCond %{THE_REQUEST} \s/+index\.php\?(/\S+) [NC]
RewriteRule ^ /%1? [R=301,L]
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top