سؤال

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