只是將我的腳趾首次插入到.htaccess URL重寫的世界中,並在第一個障礙中墮落。不過我相信我缺少明顯的東西... :)使用htaccess問題重寫網址
我的htaccess目前看起來是這樣的,這是一個安裝WordPress從/ WordPress的運行,但重新編寫,出現在域的頂級:
php_value short_open_tag 1
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase/
RewriteRule ^index\.php$ - [L]
# add a trailing slash to /wp-admin
RewriteRule ^([_0-9a-zA-Z-]+/)?wp-admin$ $1wp-admin/ [R=301,L]
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule^- [L]
RewriteRule ^([_0-9a-zA-Z-]+/)?(wp-(content|admin|includes).*) wordpress/$2 [L]
RewriteRule ^([_0-9a-zA-Z-]+/)?(.*\.php)$ wordpress/$2 [L]
RewriteRule . index.php [L]
</IfModule>
我想添加一個重寫規則採取任何人訪問: /publication-details.php?id=xxx(其中xxx是一個數字 到 /出版/酒館-XXX/
我想像這樣的東西會工作:
RewriteRule ^publication-details.php?id=([0-9]+) /publications/pub-$1 [NC]
但我試過,作爲一個規則,但它不工作 - 無論我在現有的規則中訂購它。試圖訪問/publication-details.php只是獲得一個404(Apache默認)。如果我嘗試/什麼(即沒有擴展名的網址),我得到的Wordpress 404。
我錯過了什麼?!
在此先感謝。
謝謝 - 這樣做是否有好處,而不是直接將規則插入到htacces中? – user3204476