htaccess的RewriteEngine叙述htaccess、RewriteEngine

2023-09-02 00:38:29 作者:我们隔的不只几千公里

我有一个网址是 http://www.urlbookmarking.com/书签-details.php?出价= 55 我希望它像 http://www.urlbookmarking.com/bookmark/55

I have an url which is http://www.urlbookmarking.com/bookmarks-details.php?bid=55 and I want it to be like http://www.urlbookmarking.com/bookmark/55

我写在我的htaccess的:

I wrote in my htaccess:

RewriteEngine on
RewriteRule /bid/(.*) bookmarks-details.php?bid=$1

但是,当我去的第一个URL重写引擎不适用我的规则。是否有任何错误或冲突的地方?

But when I go to the first URL the rewrite engine does not apply my rule. Is there any mistake, or conflict somewhere?

我写为全htaccess文件如下

My full htaccess file written as follows

Options +FollowSymLinks

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^.]+)$ $1.php [NC,L] 

RewriteEngine on
RewriteCond %{HTTP_HOST} ^urlbookmarking.com [NC]
RewriteRule ^(.*)$ http://www.urlbookmarking.com/$1 [L,R=301]

RewriteEngine on
RewriteRule /bid/(.*) bookmarks-details.php?bid=$1

请帮我。

推荐答案

选项+了FollowSymLinks 是可选的,如果已经配置中的的httpd.conf

The line Options +FollowSymLinks is optional if already configured in httpd.conf

Options +FollowSymLinks

RewriteEngine on

RewriteCond %{HTTP_HOST} ^urlbookmarking.com [NC]
RewriteRule ^(.*)$ http://www.urlbookmarking.com/$1 [R=301, L]

RewriteRule ^bookmark/([0-9]+)$ bookmarks-details.php?bid=$1 [NC, L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^.]+)$ $1.php [NC,L]