2015-01-09 37 views
0

我使用.htaccess文件的URL重寫,我改變了一些網址像這樣使用.htaccess文件: -在面對trobule URL重寫動態網址

RewriteRule ^home/?$ index.php [NC,L] 

,但我不知道如何我改變這個網址

/localhost/mywebiste/complete_listing.php?category=Education&city=delhi 

到這個網址

/localhost/mywebiste/education-in-delhi 

url中每個類別和城市。

我試試這個:

Rewrite-rule ^Agriculture-in-jaipur([A-Za-z0-9-]+)?$ complete_listing.php?category=education&&city=delhi [NC,L] 

但這個我改變只有一種類型的網址,每次類別和城市將被改變

回答

1

如果我是正確的,你想/本地主機/ mywebiste/教育 -in- 德里 - 2個變量

RewriteRule ^([A-Za-z0-9-]+)-in-([A-Za-z0-9-]+)$ complete_listing.php?category=$1&city=$2 [NC,L] 

注意的網址- 這將是應用的最後一條規則。

+0

感謝您的幫助,但有在URL類別的一個問題足夠的空間,和其筆記的工作誰我可以從網址自行車%20Service%20Center刪除%20 -in-Jaipur –

+0

你必須去掉空格即。 '$ string = str_replace('','',$ string);' – violator667

1
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^(.*)-in-(.*)$ complete_listing.php?category=$1&city=$2 [NC,L] 
+0

感謝您的幫助,但是url類別中有一個問題有空間及其注意事項我可以從url中移除%20 Bike%20Service%20Center-在-齋浦爾 –