我有一个htm / css模板,看似是mod_rewrite规则:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d [OR]
RewriteCond %{REQUEST_FILENAME} gallery\_remote2\.php
RewriteCond %{REQUEST_URI} !/main\.php$
RewriteRule . - [L]
RewriteCond %{THE_REQUEST} /d/([0-9]+)-([0-9]+)/([^/?]+)(\?.|\ .)
RewriteCond %{REQUEST_URI} !/main\.php$
RewriteRule . /main.php?g2_view=core.DownloadItem&g2_itemId=%1&g2_serialNumber=%2&g2_fileName=%3 [QSA,L]
RewriteCond %{THE_REQUEST} /v/([^?]+)(\?.|\ .)
RewriteCond %{REQUEST_URI} !/main\.php$
RewriteRule . /main.php?g2_path=%1 [QSA,L]
RewriteRule ^presentation/([0-9]+)$ /presentation.php?id=$1
ErrorDocument 404 /notavailable.php
</IfModule>
这部分是我的:RewriteRule ^presentation/([0-9]+)$ /presentation.php?id=$1
我现在的网址是www.domain.com/presentation.php?id=1
我想要www.domain.com/presentation/1 /
我的工作无效,并且想知道我的规则是否错误或与已经存在的规则相冲突。
编辑:
好的,我得到了这个工作:RewriteRule ^presentation/([0-9]+)$ /presentation.php?id=$1 [L]
所以www.domain.com/presentation/2我想要一条规则,最后没有斜线或斜线......但我们不能稍后处理......
现在的问题是,虽然正在检索id,但网站的行为就好像有一个表示目录,因此包括标题在内的所有相对路径都不起作用。实际上,我认为css链接已被破坏。
答案 0 :(得分:0)
实际上,如果您确实希望浏览器中的URL发生变化,那么请定义您的重写规则:
RewriteRule ^presentation/([0-9]+)$ /presentation.php?id=$1 [R=301,L]
这仅仅意味着使用新URL将HTTP状态301返回给浏览器。
这样你的浏览器无法使用相对路径查找图像,css,图像等的问题也将得到解决。