我使用htaccess在我的項目中生成乾淨的URL。.htaccess重寫規則不起作用?
一樣,我想這個URL轉換:
https://localhost/erp/profile.php?username=kopyo
到這個網址:
https://localhost/erp/profile/kopyo
我htaccess的代碼是:
Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /erp
RewriteCond %{HTTPS} !on
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
# Code I am using is this line but not working
RewriteRule profile/(.*) profile.php?username=$1
# To externally redirect /dir/foo.php to /dir/foo
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s([^.]+)\.php [NC]
RewriteRule^%1 [R,L]
# To internally forward /dir/foo to /dir/foo.php
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^(.*?)/?$ $1.php [L]
讓我知道我在做什麼在這個錯誤。由於
它是否給'HTTP 1.1 500內部服務器Error'?或重定向錯誤?或... – 2015-03-02 12:02:57
請參考下面的鏈接,你會得到你的答案: http://stackoverflow.com/questions/18929925/url-rewrite-htaccess – 2015-03-02 12:03:31