2014-09-04 160 views
1

在开始时:我没有权利编辑任何PHP网站我正在努力。.htaccess数据到另一个网址

的问题是,旧的.htaccess迷路:

有一个2个链接(我需要写向后规则):

第一: “模块标题-ID”

这是很容易做到:

RewriteRule ^([^/]+)-([^/]+)-([^/]+).html?$ index.php?mod=$1&id=$3 

正如你看到实际的链接看起来像这样

“的index.php MOD 1 & =的$ id = $ 3·”

但是我有一个问题:

“FOO page.html中吧=?” 所以我想这样的事情:

RewriteRule ^([^/]+).html\?([^/]+)\=([^/]+)$ index.php?mod=$1&$2=$3 

它的工作是这样的:”的index.php富=酒吧“

我该怎么做?

其余的看起来是这样的:

#Options +FollowSymLinks 
RewriteEngine On 
#RewriteBase '/' 

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

RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 

RewriteRule ^([^/]+)-([^/]+)-([^/]+).html?$ index.php?mod=$1&id=$3 
RewriteRule ^([^/]+).html\?([^/]+)\=([^/]+)$ index.php?mod=$1&$2=$3 [QSA,L] 
RewriteRule index.html index.php 

回答

0

您可以使用:

#Options +FollowSymLinks 
RewriteEngine On 
#RewriteBase/

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

RewriteCond %{REQUEST_FILENAME} -f [OR] 
RewriteCond %{REQUEST_FILENAME} -d 
RewriteRule^- [L] 

RewriteRule ^([^/]+)-([^/]+)-([^/]+)\.html?$ index.php?mod=$1&id=$3 [L,QSA] 

RewriteRule ^(.+?)\.html?$ index.php?mod=$1 [QSA,L] 

RewriteRule ^reservation-save\.html$ reservation.html?t=1 [QSA,L] 

RewriteRule ^index\.html$ index.php [L] 
+0

你是我心目中的英雄。非常感谢! – dudzio 2014-09-04 07:57:18

+0

所以在“?”之后一切 - 关键和价值是自动发布到变量? – dudzio 2014-09-04 07:58:38

+0

非常欢迎。是的查询字符串会自动传输到新的URL。 – anubhava 2014-09-04 08:00:59

相关问题