I want to perform these redirecttions:
example.com/a/b/c ===> example.com/index.php?p=a/b/c
example.com/d/e/f ===> example.com/index.php?p=d/e/f
example.com/area2/b/c ===> example.com/index_area2.php?p=b/c
example.com/area2/d/e ===> example.com/index_area2.php?p=d/e
This is what I have now:
RewriteRule ^area2(.*)$ /index_area2.php?p=$1 [L,QSA]
RewriteRule ^(.*)$ /index.php?p=$1 [L,QSA]
I get internal server error. what is wrong here? Each Rule works alone.
You're getting 500 error because your rules are causing infinite looping with any RewriteCond
. Have it this way:
RewriteEngine On
RewriteBase /
# If the request is for a valid directory
RewriteCond %{REQUEST_FILENAME} -d [OR]
# If the request is for a valid file
RewriteCond %{REQUEST_FILENAME} -f
# skip them from rules below
RewriteRule ^ - [L]
RewriteRule ^area2/(.+)$ index_area2.php?p=$1 [L,QSA,NC]
RewriteRule ^(.+)$ index.php?p=$1 [L,QSA]
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.