문제

I’m using that .htaccess to redirect all after slash to my index.php param :

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]

But then im trying to go mysite.co/http://someurl.co or mysite.co/http://www.someurl.co (mysite.co/www.someurl.co redirecting well) im getting error

You don't have permission to access mysite.co/http://www.someurl.co on this server.

도움이 되었습니까?

해결책

mod_rewrite engine strips all double slashes to single ones in RewriteRule so you cannot match http://www in RewriteRule. Use RewriteCond instead with THE_REQUEST parameter.

RewriteEngine On

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{THE_REQUEST} \s/+(\S+)
RewriteRule ^ /index.php?q=%1 [L,QSA]

다른 팁

Your code is unclear. What are you trying to do? This is the standard WordPress .htaccess which appears close to what you are attempting. Perhaps using that would work better:

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
RewriteRule ^http\:\/+.*$ index.php?q=$0 [L,QSA]
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top