2017-08-19 115 views
0
<Files ~ (\.php)> 
Options +SymLinksIfOwnerMatch 
</Files> 
AddDefaultCharset utf-8 
RewriteEngine on 
RewriteBase/
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^.*$ index.php [NC,L] 
RewriteRule ^([A-Za-z0-9-]+)/([0-9]+)/([0-9]+)$ index.php?lang=$1&menu=$2&submenu=$3 [L] 

源URL:example.com/index.php?lang=de &菜单= 1项&子菜单= 0 新网址:example.com/de/1/0htaccesc重写规则不起作用

载入新网址主页,但需要另一个页面

+0

问题是什么究竟,什么是你所面临的问题?目前我们根据当前的信息无法回答任何问题。 –

+0

问题:为什么网址“example.com/de/1/0”不喜欢工作URL“example.com/index.php?lang=de&menu=1&submenu=0” – Max

+0

此页上的“example.com/index.php ?lang = de&menu = 1&submenu = 0“我有”关于公司“,但是此网址为”example.com/de/1/0“加载”主页“。在重写URL我也需要“关于公司” – Max

回答

0
<Files ~ (\.php)> 
Options +SymLinksIfOwnerMatch 
</Files> 
AddDefaultCharset utf-8 
RewriteEngine on 
RewriteBase/
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^.*$ index.php [NC,L] 
RewriteRule ^([A-Za-z0-9-]+)/([0-9]+)/([0-9]+)$ index.php?lang=$1&menu=$2&submenu=$3 [L] 

如果按照这个,你告诉Apache将采取一切,这是不是一个文件或文件系统的目录,并重写的index.php。

RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^.*$ index.php [NC,L] 

所以这就是它在做什么。

为了使这个做你想要什么,你必须做出这样的:

<Files ~ (\.php)> 
Options +SymLinksIfOwnerMatch 
</Files> 
AddDefaultCharset utf-8 
RewriteEngine on 
RewriteBase/
# if file/director does not exist, and if it matches the pattern 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^([A-Za-z0-9-]+)/([0-9]+)/([0-9]+)$ index.php?lang=$1&menu=$2&submenu=$3 [QSA,L] 
# then if it did not match the pattern, send it to index.php 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^.*$ index.php [NC,L] 

请注意,您没有提供足够的信息来了解你实际上是试图实现。但我的猜测是这样的。我还假设你想将值追加到index.php(QSA)的查询字符串中,这通常是你想要的。

但它不是真的有可能进一步猜测,直到您指定的内容的所有网址都应该做的。

注意,通过匹配任何不是文件/目录,并且不经进一步的参数作为最后的命令的index.php(L),即结束请求处理重写它,它永远不会击中的第二种情况。

+0

谢谢,现在我明白了,什么是错的 – Max