当我在本地主机工作时,我应该如何更改 mod_rewrite url 的根目录

发布于 2024-08-26 14:35:01 字数 1020 浏览 3 评论 0原文

我正在从事网站维护工作。它使用 mod_rewrite 技术。但我对 mod_rewrite 很陌生。我应该如何更改 url 才能在本地主机中正常工作。 这是代码:

# Enable mod_rewrite, start rewrite engine 
Options +FollowSymLinks 
RewriteEngine on 

rewritecond %{http_host} ^electricians4u.com.au [nc]
rewriterule ^(.*)$ http://www.electricians4u.com.au/$1 [r=301,nc]

ErrorDocument 404 /error404.php

# for searching
RewriteRule ^([^/]*)-in-([^/]*)\.htm$   /search.php?searchby=$1&SearchString=$2&search.x=$3&search.y=$4&search=Find+Agent [NC] 

# for nav
RewriteRule ^electricians-in-([^/]*)-([^/]*)$ /search.php?SearchString=$1&state=&page=$2          [NC] 

# index page
RewriteRule ^find-electrician-(.*)$ /find_electrician_in.php?state=$1                    [NC,L] 

# find  page
RewriteRule ^electrician-(.*)-(.*)$ /find_electrician_in.php?state=$1&bspname=$2         [NC,L] 

# find  page
RewriteRule ^electricians-in-([^/]*)\.htm$ /search.php?state=$1&bspname=$2&locality=$3     [NC] 

请帮忙。我知道要问这个愚蠢的问题。但我不知道其他选择。

I am working on a site maintainence. It uses mod_rewrite technique. But im new to mod_rewrite. How should i change the url to work correctly in my localhost.
here's the code:

# Enable mod_rewrite, start rewrite engine 
Options +FollowSymLinks 
RewriteEngine on 

rewritecond %{http_host} ^electricians4u.com.au [nc]
rewriterule ^(.*)$ http://www.electricians4u.com.au/$1 [r=301,nc]

ErrorDocument 404 /error404.php

# for searching
RewriteRule ^([^/]*)-in-([^/]*)\.htm$   /search.php?searchby=$1&SearchString=$2&search.x=$3&search.y=$4&search=Find+Agent [NC] 

# for nav
RewriteRule ^electricians-in-([^/]*)-([^/]*)$ /search.php?SearchString=$1&state=&page=$2          [NC] 

# index page
RewriteRule ^find-electrician-(.*)$ /find_electrician_in.php?state=$1                    [NC,L] 

# find  page
RewriteRule ^electrician-(.*)-(.*)$ /find_electrician_in.php?state=$1&bspname=$2         [NC,L] 

# find  page
RewriteRule ^electricians-in-([^/]*)\.htm$ /search.php?state=$1&bspname=$2&locality=$3     [NC] 

Plz help. I know this silly question to ask. But i dont know other alternative.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

跨年 2024-09-02 14:35:01

如果其他所有内容都正确配置并且安装了所有文件,我不明白为什么这不起作用。里面没有什么具体的内容。对 .co.au 域的明确引用将不适用。

只需确保您的 Apache 配置中激活了 mod_rewrite 模块即可。

I don't see why this shouldn't work, if everything else is correctly configured otherwise, and all the files installed. There is nothing specific in there. The explicit reference to the .co.au domain won't apply.

Just make sure you have the mod_rewrite module activated in your Apache configuration.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文