試圖重寫幾個不同的URL而不改變RewriteBase。以下網址查詢:htaccess在不改變RewriteBase的情況下重寫網址而不改變rewritebase
http://example.com/directory1/directory2/job?id=100
http://example.com/directory3/directory4/profile?id=200
將成爲:
http://example.com/directory1/directory2/job/100
http://example.com/directory3/directory4/profile/200
目前的規則:
RewriteRule ^directory1/directory2/job/([0-9]+)$ ./directory1/directory2/job?id=$1 [L,QSA]
RewriteRule ^directory3/directory4/profile/([0-9]+)$ ./directory3/directory4/profile?id=$1 [L,QSA]
完整的htaccess:
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews
Options +FollowSymLinks
</IfModule>
RewriteEngine On
# Redirect Trailing Slashes...
RewriteRule ^(.*)/$ /$1 [L,R=301]
# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule^index.php [L]
RewriteRule ^directory1/directory2/job/([0-9]+)$ ./directory1/directory2/job?id=$1 [L,QSA]
RewriteRule ^directory3/directory4/profile/([0-9]+)$ ./directory3/directory4/profile?id=$1 [L,QSA]
</IfModule>
那麼有什麼不符合規則的問題? – anubhava
沒有錯誤。用完整的htaccess編輯問題 – Klav