richardk wrote:Try
- Code: Select all
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteRule ^(.+)/$ /$1 [R=301,L]
Thanks a lot for this richardk
, is working great when I use 2 or more variables:
http://example.com/page/subpage/ goes to
http://example.com/page/subpageThe problem is that I'm using 4 simple rewrites:
- Code: Select all
Options +FollowSymlinks
RewriteEngine on
### force NO slash at the end ###
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteRule ^(.+)/$ /$1 [R=301]
### 1 variable ###
RewriteRule ^([a-z0-9_-]+)$ /?p=$1 [L]
### 2 variables ###
RewriteRule ^([a-z0-9_-]+)/([a-z0-9_-]+)$ /?p=$1&q=$2 [L]
### 3 variables ###
RewriteRule ^([a-z0-9_-]+)/([a-z0-9_-]+)/([a-z0-9_-]+)$ /?p=$1&q=$2&r=$3 [L]
### 4 variables ###
RewriteRule ^([a-z0-9_-]+)/([a-z0-9_-]+)/([a-z0-9_-]+)/([a-z0-9_-]+)$ /?p=$1&q=$2&r=$3&s=$4 [L]
Works great when I have 2, 3 or 4 variables, but the my problem lies when I have just 1 variable:
If I go to
http://example.com/a_fake_folder/ the page is redirected to
http://example.com/a_fake_folder and I get the variable
p=a_fake_folder ..everything ok
If I go to
http://example.com/a_real_folder/ the page goes to the
<a_real_folder> folder in the root of my website, and not to
http://example.com/a_real_folder to get the variable
p=a_real_folder
If I deactivate the option to show the content of my folders, it goes to a 403 forbidden page.
I don't know if one of my rules is wrong, or if the rule that richardk wrote only works if the folder doesn't really exists.
Any comments or help is really appreciated.