抱歉英语不好,英语不是我的母语所以我正在努力做到最好。
当我尝试使我的URL更友好时,我遇到了mod_rewrite的问题。 我不会这样做我的网址:
http://domain.eu/blog?page=2
对此:
http://domain.eu/blog/2/
我目前的代码:
ErrorDocument 404 /404.php
Options -MultiViews
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^\.]+)$ $1.php [NC,L]
# WWW to not WWW.
#RewriteCond %{HTTP_HOST} ^www\.rasolutions\.eu$
#RewriteRule ^/?$ "http\:\/\/rasolutions\.eu\/" [R=301]
# No PERL access/
RewriteCond %{HTTP_USER_AGENT} libwww-perl.*
RewriteRule .* – [F,L]
# Blog SEO Urls.
RewriteRule ^blog/([0-9]*)/?$ blog.php?page=$1 [NC,L]
RewriteRule ^blogitem/([0-9]*)/?$ blogitem.php?id=$1 [NC,L]
# Home redirect.
DirectoryIndex home.php
答案 0 :(得分:1)
首先 - 请确保您已通过声明
在.htaccess文件中启用了mod_rewrite
RewriteEngine on
如果已设置,请确保通过设置
禁用Multiviews
选项
Options -Multiviews
在服务器的配置文件
上类似的问题: mod_rewrite not passing querystring
现在我看到了你的完整.htaccess - 规则的顺序是错误的
你应该先检查一下:
# Blog SEO Urls.
RewriteRule ^blog/([0-9]*)/?$ blog.php?page=$1 [NC,L]
RewriteRule ^blogitem/([0-9]*)/?$ blogitem.php?id=$1 [NC,L]
仅在此之后
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^\.]+)$ $1.php [NC,L]
完整文件应如下所示:
ErrorDocument 404 /404.php
# Home redirect.
DirectoryIndex home.php
Options -MultiViews
RewriteEngine On
# No PERL access/
RewriteCond %{HTTP_USER_AGENT} libwww-perl.*
RewriteRule .* – [F,L]
# WWW to not WWW.
#RewriteCond %{HTTP_HOST} ^www\.rasolutions\.eu$
#RewriteRule ^/?$ "http\:\/\/rasolutions\.eu\/" [R=301]
# Blog SEO Urls.
RewriteRule ^blog/([0-9]*)/?$ blog.php?page=$1 [NC,L]
RewriteRule ^blogitem/([0-9]*)/?$ blogitem.php?id=$1 [NC,L]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^\.]+)$ $1.php [NC,L]