Frage

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.

War es hilfreich?

Lösung

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]

Andere Tipps

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]
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top