htaccess的重写条件不工作 [英] htaccess rewrite condition not working
问题描述
我的工作在我的网站的网址。我刚刚重写URL从
http://www.website.com/index.php?url=some-text
到
http://www.website.com/some-text
有关此我用下面的$ C $的.htaccess了C
选项+ SymLinksIfOwnerMatch
RewriteEngine叙述上
的RewriteBase /
的RewriteCond%{} REQUEST_FILENAME!-f
的RewriteCond%{} REQUEST_FILENAME!-d
的RewriteCond%{} REQUEST_FILENAME!-l
重写规则^(。*)$的index.php?URL = $ 1 [L,QSA]
现在,我想再添变数页号
的URL。
http://www.website.com/index.php?url=some-text&page=1
我要重写它像
http://www.website.com/some-text/1/
和
http://www.website.com/some-text/1
我曾尝试以下code,但由于某种原因,它不工作,它显示我的服务器错误。
的RewriteCond%{} REQUEST_FILENAME!-f
的RewriteCond%{} REQUEST_FILENAME!-d
的RewriteCond%{} REQUEST_FILENAME!-l
重写规则^ / $的index.php 1 URL = $&AMP(*)(*);?页= $ 2 [L,QSA]
1重写规则^ / / $的index.php URL = $&AMP(*)(*);?页= $ 2 [L,QSA]
您不需要2个新的规则。只要一有可选的 /
就足够了。你完全code:
选项+ SymLinksIfOwnerMatch -MultiViews
RewriteEngine叙述上
的RewriteBase /
的RewriteCond%{} REQUEST_FILENAME!-f
的RewriteCond%{} REQUEST_FILENAME!-d
的RewriteCond%{} REQUEST_FILENAME!-l
?重写规则^([^ /] +)/([^ /] +)/ $的index.php 1 URL = $&放大器;页= $ 2 [L,QSA]
的RewriteCond%{} REQUEST_FILENAME!-f
的RewriteCond%{} REQUEST_FILENAME!-d
的RewriteCond%{} REQUEST_FILENAME!-l
重写规则^([^ /] +)/ $的index.php?URL = $ 1 [L,QSA]
在新的code另一个问题是,的RewriteCond
没有得到应用的最后重写规则
,因为这些适用于第二天重写规则
只。
I am working on URL of my website. I have just rewrite the URL From
http://www.website.com/index.php?url=some-text
to
http://www.website.com/some-text
For this I'm using following code of .htaccess
Options +SymLinksIfOwnerMatch
RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^(.*)$ index.php?url=$1 [L,QSA]
Now, I want to add another variable page number
in URL.
http://www.website.com/index.php?url=some-text&page=1
I want to rewrite it like
http://www.website.com/some-text/1/
AND
http://www.website.com/some-text/1
I have tried following code but some reason it is not working, it showing me server error.
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^(.*)/(.*)$ index.php?url=$1&page=$2 [L,QSA]
RewriteRule ^(.*)/(.*)/$ index.php?url=$1&page=$2 [L,QSA]
You don't need 2 new rules. Just one with optional /
will be enough. Your complete code:
Options +SymLinksIfOwnerMatch -MultiViews
RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^([^/]+)/([^/]+)/?$ index.php?url=$1&page=$2 [L,QSA]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^([^/]+)/?$ index.php?url=$1 [L,QSA]
Another problem in your new code is that RewriteCond
are not getting applied for last RewriteRule
since these are applicable to very next RewriteRule
only.
这篇关于htaccess的重写条件不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!