Regex htaccess没有';I don’我没料到会这样
我有以下脚本:Regex htaccess没有';I don’我没料到会这样,regex,apache,.htaccess,mod-rewrite,Regex,Apache,.htaccess,Mod Rewrite,我有以下脚本: Options +FollowSymLinks RewriteEngine On # PATH RewriteBase /bbv/ # ERROR RULE ErrorDocument 404 /bbv/404.php # WORKS RewriteRule ^home$ index.php RewriteRule ^contact$ contact.php RewriteRule ^(.*)\.html$ template_cat.php?cat=$1 [L] # TH
Options +FollowSymLinks
RewriteEngine On
# PATH
RewriteBase /bbv/
# ERROR RULE
ErrorDocument 404 /bbv/404.php
# WORKS
RewriteRule ^home$ index.php
RewriteRule ^contact$ contact.php
RewriteRule ^(.*)\.html$ template_cat.php?cat=$1 [L]
# THIS DOES NOT WORK
RewriteRule ^(.*)\(.*)-(.*)$ template_prod.php?cat=$1&prod=$2&id=$3 [L]
RewriteRule ^(.*)$ template_cat.php?cat=$1 [L]
我想变成这样:localhost/bbv/category和localhost/bbv/category/product id
错在哪里?tx.使用此代码:
# ERROR RULE
ErrorDocument 404 /bbv/404.php
Options +FollowSymLinks
RewriteEngine On
# PATH
RewriteBase /bbv/
RewriteCond %{REQUEST_FILENAME} -d [OR]
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule ^ - [L]
# WORKS
RewriteRule ^home$ index.php [L]
RewriteRule ^contact$ contact.php [L]
RewriteRule ^([^.]+)\.html$ template_cat.php?cat=$1 [L,QSA]
RewriteRule ^([^/]+)/([^-]+)-(.+)$ template_prod.php?cat=$1&prod=$2&id=$3 [L,QSA]
RewriteRule ^(.+)$ template_cat.php?cat=$1 [L,QSA]
localhost/bbv/category css加载是由于您使用了相对链接。在css、js、图像文件中使用绝对路径,而不是相对路径。这意味着您必须确保这些文件的路径以
http://
或斜杠/
开头。您可以尝试将此添加到页面的HTML标题中:
tx,我使用过,现在唯一的问题是404重定向。。。页面未正确重定向它应该是:
或任何您的路径。与“/bbv/”相同。。。但我认为这与这个规则有冲突:RewriteRule^(+)$template_cat.php?cat=$1[L,QSA],如果禁用它,它就会工作。