我已經看過每個問題和每個Apache的服務器reWriteRule的例子......沒有任何工作。mod_rewrite乾淨的URL不工作
我只需要改變 http://beta.EXAMPLE.com/profile.php?profile_name=ntgCleaner 到 http://beta.EXAMPLE.com/ntgCleaner
我必須看到,如果my .htaccess file is being read,並查看if mod_rewrite is enabled,他們都完全正常工作。
出於某種原因,我遇到的例子不適合我。以下是一些例子。
RewriteEngine On
RewriteRule /(.*)$ /profile.php?username=$1
,
RewriteEngine On
RewriteBase/
RewriteRule ^profile\/(.*)$ ./profile.php?profileId=$1 [L,NC,QSA]
和
Options +FollowSymlinks
RewriteEngine on
RewriteOptions MaxRedirects=10
RewriteRule ^([a-zA-Z0-9_-]+)$ profile.php?profile_name=$1
RewriteRule ^([a-zA-Z0-9_-]+)/$ profile.php?profile_name=$1
但所有這些工作。這是因爲我使用的是一個子域嗎?我計劃在完成網站時最終將BETA中的子域名切換到www。
有什麼建議嗎?
噢,對不起,我只是希望它使用PROFILE_NAME作爲清潔網址,所以從example.com/ profile.php?profile_name = ntgCleaner to example.com/ntgCleaner 那些我們只是我想要的例子 – ntgCleaner 2012-08-10 18:28:32
這正是我需要的!我不認爲request_filename必須處理任何事情......謝謝! – ntgCleaner 2012-08-10 18:30:56
@ntgCleaner這是一種不會無限循環的方式,因爲如果URI指向現有資源(如profile.php),它將不會重新重寫。 – 2012-08-10 18:33:46