只是将我的脚趾首次插入到.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