与当地的.htaccess在XAMPP重写URL重写、当地、XAMPP、htaccess

2023-09-02 00:33:42 作者:胸怀天下不老人

我.htacces以

   RewriteEngine on
   RewriteBase /

(我试了一下也没有的RewriteBase ...)

(I tried it also without RewriteBase...)

我尝试了所有的以下重写规则重写URL

I tried all of the following rewriting rules to rewrite the URL

的index.php?页=新闻

/博客

在重写规则^ /([ - A-ZA-Z0-9] +)/([ - A-ZA-Z0-9] +)/博客$ 的index.php?网页= $ 1 [L] 在重写规则^([^ /] *)/博客$ /sites/blog/index.php?page=$1 [L] 在重写规则([A-ZA-Z] +)/([A-ZA-Z] +)/博客$的index.php?网页= $ 1 [L] RewriteRule ^/?([-A-Za-z0-9]+)/([-A-Za-z0-9]+)/blog$ index.php?page=$1 [L] RewriteRule ^([^/]*)/blog$ /sites/blog/index.php?page=$1 [L] RewriteRule ([a-zA-z]+)/([a-zA-z]+)/blog$ index.php?page=$1 [L]

没有什么工作 - 没有错误。 mod_rewrite的安装和工作。我重新启动Apache和MySQL每次我在我的.htaccess改变一些东西。

Nothing works - no error. Mod_rewrite is installed and working. I restarted Apache and MySQL everytime I changed something in my .htaccess.

我也想改变我的URL看起来像这样... index.php?page=single_news&category=release&id=9&headline=Beastie%20Boys%20III

I also want to change my URLs which looks like this... index.php?page=single_news&category=release&id=9&headline=Beastie%20Boys%20III

...为:博客/发行/ 9-野兽-BOYS-III

我很失落。希望你能帮助我。

I am lost. Hope you can help me.

推荐答案

这里的解决方案,以改变从 HTTP链接://www.domain.tld/index.php页=博客的http://www.domain.tld/blog 是:

Here's the solution to change links from http://www.domain.tld/index.php?page=blog to http://www.domain.tld/blog is:

RewriteEngine On

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^w+$ index.php?page=$0 [L]
RewriteCond %{THE_REQUEST} index.php
RewriteCond %{QUERY_STRING} ^page=(w+)$
RewriteRule ^index.php$ /%1? [R=301,L]

和像链接: http://www.domain.tld/index.php?page=single_news&id=1&headline=This%20Is%20A%Headline

的解决方案是:

RewriteRule ^blog/(d+)-([w-]+)$ index.php?page=single_news&id=$1&headline=$2

使用此code后,链接如下:的http://www.domain.tld/blog/2-this-is-a-headline