【发布时间】:2016-04-06 10:54:32
【问题描述】:
我的 url 有问题,当 dot 出现在 url 中时,它会给出 404 错误。
网址:http://example.com/Samsung-Galaxy-Mega-5.8
我在 htaccess 中使用了一些代码,但它不能正常工作。
RewriteRule ^([a-zA-Z_\-]+)/?([a-zA-Z0-9\-=&_@\.]*)$ /$1.php?$2 [QSA,L]
编辑(从评论中复制):
RewriteEngine on
Options -Indexes
#RewriteCond %{HTTP_HOST} ^([a-z0-9-A-Z_]*).([a-z]*)$
#RewriteRule ^(.*)$ %1.%2/$1 [L,R=301]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
#RewriteRule ^([a-zA-Z0-9_-]+)$ show_mobile.php?bid=$1&brandname=$2
RewriteRule ^([a-zA-Z0-9\-]+)-([a-zA-Z0-9\-]+)$ show_mobile.php?bid=$2&brandname=$1
【问题讨论】:
-
向我们展示更多您的 [.htaccess]。这本身正在寻找您提供的示例 URL 中不存在的
/?。 -
这里是我的 htaccess 完整代码: RewriteEngine on Options -Indexes #RewriteCond %{HTTP_HOST} ^([a-z0-9-A-Z_]*).([a-z]*)$ # RewriteRule ^(.*)$ %1.%2/$1 [L,R=301] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d #RewriteRule ^([a-zA-Z0-9_-]+)$ show_mobile.php?bid=$1&brandname=$2 RewriteRule ^([a-zA-Z0-9\-]+)-([a-zA-Z0-9\-]+)$ show_mobile.php?bid=$2&brandname =$1