2016-01-20 131 views
2

我有問題重新書寫網址從htaccess的:URL重寫本期的查詢字符串參數

http://localhost/cs/compare?slug=wash-safe-industries.html  

http://localhost/cs/compare/wash-safe-industries.html 

我曾嘗試下面的代碼在.htaccess但不起作用我也搜索了各種網站,但仍面臨問題

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

RewriteRule ^/?compare/(.*?)/?$ /compare.php?slug=$1 [L] 

也試過下面的代碼行

RewriteRule ^cs/(.*)$ cs/compare.php?slug=$1 [L,QSA] 

請幫我謝謝

+0

@anubhava是它拋出404錯誤 –

+1

@anubhava在cs文件夾中 –

回答

2

試試這個的.htaccess中/cs/子目錄:

Options -MultiViews 
RewriteEngine on 
RewriteBase /cs/ 

RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^compare/(.+?)/?$ compare.php?slug=$1 [L,NC,QSA] 
0

你必須寫如下,試試這個。

重寫規則^比較/洗安全-industries.html比較蛞蝓=洗安全-industries.html

1

嘗試使用的代碼下面一行:

Options -MultiViews 
RewriteEngine On 
RewriteRule ^compare/(.+?)/?$ compare.php?slug=$1 [L,NC,QSA] 
相關問題