mod_rewrite不起作用htaccess [英] mod_rewrite not working htaccess
问题描述
我有一个具有11个子域的网站。我有一个主要的 htaccess
public_html
根文件夹中的code>文件具有常见的共享特征,例如 cache
等。我有单独的内容我使用 mod_rewrite
的每个子域根文件夹中的 htaccess
个文件,但是我无法重写网址。我正在尝试将其从 dundaah.com/days/content.php?day=thur
更改为更干净的 dundaah.com/thursday
,并将子域 music.dundaah.com/days/content.php?day=thur
转换为首选的 music .dundaah.com / thursday
。到目前为止,我第一个研究的代码仅使我进入URL dundaah.com/day/thur
,而第二个则使我进入URL dundaah.com/thursday
仍然给我一个404错误。我没有更改网站的内部链接,这是一个难题吗?有人可以帮忙吗?谢谢
I have a website with 11 sub-domains.I have one main htaccess
file in the public_html
root folder that has the common shared traits like cache
etc. I have separate htaccess
files in each of the sub-domain root folders where I use mod_rewrite
however I can't get it to rewrite the URL. I'm trying to change it from dundaah.com/days/content.php?day=thur
to a much cleaner dundaah.com/thursday
and for the sub-domains music.dundaah.com/days/content.php?day=thur
to a preferred music.dundaah.com/thursday
. My 1st researched code so far only gets me to the URL dundaah.com/day/thur
and the 2nd to dundaah.com/thursday
still gives me a 404 error. I have not changed the internal links of the site, is this a prolem? Could anyone help? Thanks
<IfModule mod_rewrite.c>
Options +FollowSymlinks
# enable the rewrite engine
RewriteEngine On
RewriteCond %{REQUEST_URI} ^/days/content.php
RewriteCond %{QUERY_STRING} ^day=([a-z]+)$
RewriteRule ^(.*)$ /days/%1? [R,L]
# or for individual pages
RewriteCond %{REQUEST_URI} ^/days/content.php
RewriteCond %{QUERY_STRING} ^day=thur$
RewriteRule ^(.*)$ /thursday? [R,L]
</IfModule>
推荐答案
抱歉,我是在网站上使用错误的文件夹目录系统的人。这是一个正在使用的
My apologies, I was the one using a bad folder directory system in my website. This is the one is was using
public_html(www目录)
-index.php
-vidz(sub-域)
-index.php
-天
-_imports
-css
-js
-php
-content.php
-contact.php
这是我升级的系统
public_html(www目录)
-index.php
-vidz(子域)
-index.php
-content.php
-contact.php
-资产
-_imports
-css
-js
-php
这样可以使链接具有< a href ='monday'> Mon< / a>
并使用 .htaccess
下面的重定向规则。
Which makes it possible to have the links as <a href='monday'>Mon</a>
and use the .htaccess
redirect rules below.
<IfModule mod_rewrite.c>
Options +FollowSymlinks
RewriteEngine On
RewriteRule ^monday$ content.php?day=mon [NC,L]
RewriteRule ^tuesday$ content.php?day=tue [NC,L]
RewriteRule ^wednesday$ content.php?day=wed [NC,L]
RewriteRule ^thursday$ content.php?day=thur [NC,L]
RewriteRule ^friday$ content.php?day=fri [NC,L]
RewriteRule ^saturday$ content.php?day=sat [NC,L]
RewriteRule ^sunday$ content.php?day=sun [NC,L]
RewriteRule ^contact$ contact.php [NC,L]
</IfModule>
感谢所有回答!它帮助我意识到了这一点。
Thanks to all who answered! It helped me realize this.
这篇关于mod_rewrite不起作用htaccess的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!