# php_value session.cookie_domain .rhr.fm
# Enable Rewrite Engine
RewriteEngine on
#Create friendly URL
RewriteRule ^(data|cache)($|/) - [L]
RewriteRule ^([^/]+) index.php?page=$1 [L]
你好再次Stackoverflow!
我想在我的网站上重定向SEO的URL,那
www.example.com/about
www.example.com/?page=about
和
www.example.com/about/
www.example.com?page=about
但dirs数据和缓存被排除在外,所以
www.example.com/data/js/page.js
不会重定向到
www.example.com/?page=data/js/page.js
我已经尝试了上面的代码但是没有用 – $_GET [‘page’]总是转储index.php.
请你帮助我好吗?
提前致谢!
解决方法:
这应该工作:
RewriteEngine on
#Create friendly URL
RewriteRule ^(data|cache)($|/) - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]+)/?$/index.php?page=$1 [L,QSA]
由于2个RewriteCond语句,第二个规则将跳过重写的所有文件和目录.
标签:apache,php,htaccess,mod-rewrite
来源: https://codeday.me/bug/20190629/1324300.html