我有一個我自己創建的CMS,我有一個外部鏈接,它顯示用戶創建的網頁。PHP - 使URL更小,但具有相同的功能
的鏈接是:http://localhost/CMS/www/users_template/{user_name}
是否有可能更改的鏈接,使其:
http://localhost/CMS/{user_name}
但它應該仍然顯示網頁沒有任何錯誤?
我想我應該編輯我的.htaccess
文件,但不知道該怎麼做。我以前從未編輯過.htaccess
文件。
我有一個我自己創建的CMS,我有一個外部鏈接,它顯示用戶創建的網頁。PHP - 使URL更小,但具有相同的功能
的鏈接是:http://localhost/CMS/www/users_template/{user_name}
是否有可能更改的鏈接,使其:
http://localhost/CMS/{user_name}
但它應該仍然顯示網頁沒有任何錯誤?
我想我應該編輯我的.htaccess
文件,但不知道該怎麼做。我以前從未編輯過.htaccess
文件。
這是重複的。
請查看.htaccess
:removing part of url path and stay at base
RewriteEngine On
RewriteBase /CMS/
RewriteRule ^www/users_template/(.*)$ $1 [L,R=301,QSA]
感謝您的回答@demodave - 未來如果您發現重複,請將其標記爲這樣。 – Lag
你是如何顯示的?你不能修改字符串嗎? – Demodave
關於乾淨網址的搜索 – aidinMC
請參閱:http://httpd.apache.org/docs/current/mod/mod_rewrite.html – CD001