目前在我的网站上,访问者可以通过访问“www.mywebsite.com/index.php?post=123”直接访问不同的帖子,其中123是帖子编号。
我试图使用htaccess稍微清理直接链接,所需的结果是用户可以访问“www.mywebsite.com/123”并且htaccess会将它们带到“www.mywebsite.com/index.php” ?交= 123。
我尝试使用以下Modrewrite,但它指示我遇到404错误:
RewriteRule ^/([0-9]+)$ /index.php?videoID=$1 [QSA]我确信Modrewrite模块正在运行,因为我正在使用其他规则。 这是我的整个.htaccess文件:
RewriteEngine On RewriteRule ^/([0-9]+)$ /index.php?videoID=$1 [QSA] RewriteCond %{HTTP_HOST} !^www\. RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]Currently on my website visitors can directly access different posts by going to "www.mywebsite.com/index.php?post=123", where 123 is the post number.
I am trying to use htaccess to clean up the direct link up slightly, the desired result is that the user can go to "www.mywebsite.com/123" and htaccess will take them to "www.mywebsite.com/index.php?post=123.
I have tried using the following Modrewrite but it is directing me to a 404 error:
RewriteRule ^/([0-9]+)$ /index.php?videoID=$1 [QSA]I am sure that the Modrewrite module is working because I am using other rules aswell. Here is my entire .htaccess file:
RewriteEngine On RewriteRule ^/([0-9]+)$ /index.php?videoID=$1 [QSA] RewriteCond %{HTTP_HOST} !^www\. RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]最满意答案
如果这些规则在.htaccess文件中,则需要从用于匹配URI的正则表达式中删除前缀(前导斜杠):
RewriteRule ^([0-9]+)$ /index.php?videoID=$1 [QSA]If these rules are in your .htaccess file, you need to remove the prefix (the leading slash) from the regular expression used to match against the URI:
RewriteRule ^([0-9]+)$ /index.php?videoID=$1 [QSA]更多推荐
发布评论