我有一个具有以下路径的cms : cms/administrator/index.php
我做了下面的行重定向到此,同时只在我的站点url之后输入/cms。
#CMS rewrite
RewriteRule ^cms/$ /cms/administrator/index.php [L]
但是,这一行不重写我的cms文件夹中的索引文件,它将重定向到catlisting.php,这一行在后面添加了几行:
RewriteRule ^([\w-]+)/?$ catlisting.php?alias=$1 [QSA,L]
为什么在输入: website.nl/cms时使用这个规则?
这是我的整个htaccess文件:
DirectoryIndex
RewriteEngine on
RewriteBase /
RewriteCond %{HTTPS} off [OR]
RewriteCond %{HTTP_HOST} ^www\. [NC]
RewriteCond %{HTTP_HOST} ^(?:www\.)?(.+)$ [NC]
RewriteRule ^ https://%1%{REQUEST_URI} [L,NE,R=301]
#Indexes uitzetten
Options -Indexes
#Cross site access toestaan
Header set Access-Control-Allow-Origin "*"
Header add Access-Control-Allow-Headers "origin, x-requested-with, content-type"
#Sitename
DirectoryIndex index.php
#CMS rewrite
RewriteRule ^cms/$ /cms/administrator/index.php [L]
RewriteRule ^home index.php [QSA,L]
RewriteRule ^overzicht shopping-cart-page.php [QSA,L]
RewriteRule ^bestellen checkout.php [QSA,L]
RewriteRule ^contact contact.php [QSA,L]
RewriteRule ^vragen vragen.php [QSA,L]
RewriteRule ^status success.php [QSA,L]
RewriteRule ^voorwaarden voorwaard.php [QSA,L]
RewriteRule ^info/(.*).html contentlisting.php?alias=$1 [QSA,L]
RewriteRule ^verhuur/(.*)/ lp.php?alias=$1 [QSA,L]
RewriteRule ^(.*).html content.php?alias=$1 [QSA,L]
#Zorg ervoor dat onderstaande regels alleen worden uitgevoerd als het geen folder (d) is of een file (f)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
#LP
RewriteRule ^c-[^/]+/(.+)$ /verhuur/$1 [L,R=301]
#Shop
RewriteRule ^([\w-]+)/([\w-]+)/?$ product-page.php?cat=$1&alias=$2 [QSA,L]
RewriteRule ^([\w-]+)/?$ catlisting.php?alias=$1 [QSA,L]
#ErrorPages
ErrorDocument 404 /error/404.php
ErrorDocument 403 /error/403.php
ErrorDocument 500 /error/500.php
ErrorDocument 501 /error/501.php
ErrorDocument 503 /error/503.php
ErrorDocument 504 /error/504.php
发布于 2018-05-28 04:25:26
我认为问题在于cms
规则模式^cms/$
中的斜斜杠。您的模式将cms
uri与traling斜杠( /cms/
)匹配,并且它无法匹配/cms
(没有斜杠)。
您的/cms
uri将被重写为catlisting.php?alias=$1
,因为最后一条规则有一个catch所有模式,其中包含一个可选的斜杠^([\w-]+)/?$
,该斜杠与/cms
和/cms/
匹配。
要解决这个问题,您需要从您的cms
重写模式中删除traling斜杠。
RewriteRule ^cms$ /cms/administrator/index.php [L]
https://stackoverflow.com/questions/50564168
复制相似问题