.htaccess文件我无法使其正常工作

时间:2014-07-11 15:41:40

标签: regex apache .htaccess mod-rewrite url-rewriting

免责声明:我对网址重写一无所知

目前我的网址看起来像

legalHQWithNewAddressTable/legalHQ/public/admin/Parties.php?caseid=7 (any number basically)

但是我怎么能让它看起来像下面的

legalHQWithNewAddressTable/legalHQ/public/admin/Parties/caseid/7/

我正在尝试但没有工作RewriteRule ^([a-zA-Z0-9]+)/?

请不要让事情变得复杂我对网址重写一无所知,所以请尽量保持简单。

任何想法?

2 个答案:

答案 0 :(得分:3)

尝试将这些规则添加到/legalHQWithNewAddressTable/legalHQ/public/文件夹中的htaccess文件中:

RewriteEngine On
RewriteBase /legalHQWithNewAddressTable/legalHQ/public/

RewriteCond %{THE_REQUEST} /admin/([A-Za-z0-9]+)\.php\?caseid=([0-9]+)&?([^\ ]*)
RewriteRule ^ admin/%1/caseid/%2/?%3 [L,R]

RewriteRule ^admin/([A-Za-z0-9]+)/caseid/([0-9]+)/ admin/$1.php?caseid=$2 [L,QSA]

答案 1 :(得分:1)

将此规则放在/legalHQWithNewAddressTable/legalHQ/public/admin/.htaccess

Options -MultiViews
RewriteEngine On
RewriteBase /legalHQWithNewAddressTable/legalHQ/public/admin/

RewriteRule ^Parties/caseid/([0-9]+)/?$ Parties.php?caseid=$1 [L,QSA,NC]