[英]Apache - remove .php and .html file extensions using mod_rewrite in httpd.conf
[英]Using Mod_Rewrite in HTTPD.CONF file
我想重寫URL,以便用戶去;
http://www.example.com/applications/newWeb/www/index.php?page=48&thiscontent=2660&date=2013-10-11&pubType=0&PublishTime=09:30:00&from=home&tabOption=1
如果URL包含thiscontent=2660
(在上面的例子中,它確實如此)我想將它們重定向到;
http://www.example.come/index.php/publications/finance-and-economics/departmental-resources
我有大約30種不同的thiscontent=XXXX
類型,並想象我將不得不復制和編輯這個規則30個不同的時間,因為我的舊網站的任何鏈接仍然在那里敲門。
我可以訪問我的httpd.conf文件,但之前從未做過mod_rewrite。
我也不需要在錯誤日志中顯示為301s。 那會發生嗎? 因為此刻有數百個!
首先,您需要確保加載mod_rewrite。 這行應該在你的httpd.conf中取消注釋:
LoadModule rewrite_module modules/mod_rewrite.so
然后你可以使用這些規則:
RewriteEngine On
RewriteCond %{QUERY_STRING} (^|&)thiscontent=2660(&|$)
RewriteRule ^/?applications/newWeb/www/index\.php$ http://www.example.come/index.php/publications/finance-and-economics/departmental-resources? [L,R=301]
是的,你需要專門設置每一個,所以你需要30個(但只需要RewriteEngine On
一次。你也可以將這些規則放在你的文檔根目錄中的htaccess文件中。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.