[英].htaccess mod_rewrite doesnt work as I (think) i configured it
I try using mod_rewrite but it doesn't seem to work, probally a stupid error on my side. 我尝试使用mod_rewrite,但它似乎不起作用,可能是我这边的一个愚蠢错误。
when i go to index.php?page=home i want to make the url cleaner, I get no error but it also doesn't work 当我转到index.php?page = home时,我想使网址更整洁,但没有出现错误,但它也不起作用
this is in my .htaccess: 这是在我的.htaccess文件中:
RewriteEngine On # Turn on the rewriting engine
RewriteRule ^page/([A-Za-z0-9-]+)/?$ index.php?page=$1 [NC]
The rule you have in htaccess only changes new links to the old ones ie /page/something
to /index.php?page=something
. 您在htaccess中拥有的规则仅将新链接更改为旧链接,即
/page/something
更改为/index.php?page=something
。 This doesnt handle your old links.If you don't want your old links to be accessible you can redirect them to the new url format (cleaner version) using RewriteRule. 这不会处理您的旧链接。如果您不希望访问旧链接,则可以使用RewriteRule将其重定向到新的url格式(更干净的版本)。
Add the following lines above your existing rules but bellow RewriteEngine on
在现有规则上方添加以下几行,但在以下位置加上
RewriteEngine on
RewriteCond %{THE_REQUEST} /index.php\?page=([^\s]+) [NC]
RewriteRule ^ /page/%1? [L,R]
To fix the css issue see this post Seo Friendly Url css img js not working 要解决CSS问题,请参阅此帖子Seo Friendly Url css img js无法正常工作
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.