我有两个htaccess文件,其中一个位于根目录,另一个位于 gifts / 目录中。
Root .htaccess包含:
RewriteEngine on
RewriteCond %{REQUEST_URI} /gifts/
RewriteRule gifts/([A-Za-z0-9]+(?:-[A-Za-z0-9]+)*)$ gifts/catalog.php?catalog=$1 [NC,L]
RewriteCond %{REQUEST_URI} /gifts/
RewriteRule gifts/([A-Za-z0-9]+(?:-[A-Za-z0-9]+)*)/([0-9]+)$ gifts/catalog.php?catalog=$1&page=$2 [NC,L]
礼物/ .htaccess包含:
RewriteEngine on
RewriteCond %{HTTP_HOST} ^gifts.example.com$ [NC]
RewriteRule ^([A-Za-z0-9]+(?:-[A-Za-z0-9]+)*)$ /catalog.php?catalog=$1 [NC,L]
RewriteCond %{HTTP_HOST} ^gifts.example.com$ [NC]
RewriteRule ^([A-Za-z0-9]+(?:-[A-Za-z0-9]+)*)/([0-9]+)$ /catalog.php?catalog=$1&page=$2 [NC,L]
当我转到以下网址时:
可行,但以下网址不起作用
发现
未找到错误
答案 0 :(得分:1)
尝试gifts/.htaccess
:
RewriteEngine on
RewriteBase /gifts/
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([A-Za-z0-9-]+)/?$ catalog.php?catalog=$1 [QSA,L]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([A-Za-z0-9-]+)/([0-9]+)/?$ catalog.php?catalog=$1&page=$2 [QSA,L]