【问题标题】:dot in url giving an error网址中的点给出错误
【发布时间】:2016-04-06 17:42:56
【问题描述】:

当我的网址中有一个点时,我收到 404 错误,例如:http://example.com/Samsung-Galaxy-Mega-5.8

这里是我的完整 htaccess 代码:

RewriteEngine on
Options -Indexes

#RewriteCond %{HTTP_HOST} ^([a-z0-9-A-Z_]*).([a-z]*)$
#RewriteRule ^(.*)$ http://www.%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 redirect


    【解决方案1】:

    调整您的正则表达式以在第一个连字符后允许DOT

    Options -Indexes
    RewriteEngine on
    
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^([a-zA-Z0-9-]+)-([\w.-]+)/?$ show_mobile.php?bid=$2&brandname=$1 [L,QSA]
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-08-08
      • 1970-01-01
      相关资源
      最近更新 更多