简体   繁体   English

使用mod_rewrite的htaccess自定义网址列表

[英]htaccess custom url listing using mod_rewrite

I have used .htaccess to successfully mask urls with custom, clean urls in the style of subdirectories for the top level of a domain: 我已经使用.htaccess成功地使用域顶级子目录样式的自定义干净URL来屏蔽URL:

normal .htaccess config (works) 正常的.htaccess配置(有效)

RewriteCond %{REQUEST_FILENAME} -f
RewriteRule ^ - [L]
RewriteRule ^([^/]+)/([^/]+)$ /index.php?page=$1&subject=$2 [QSA]
RewriteRule ^([^/]+)$ /index.php?page=$1 [QSA]

gives me: 给我:

/page/subject /页/主题

/page /页

Now, in using specific deployments for different PHP files, I would like to make subset directories for said deployments as in: 现在,在为不同的PHP文件使用特定的部署时,我想为所述部署创建子目录,如下所示:

desired additional config (not working - throws 500 errors) 所需的其他配置(不起作用-引发500个错误)

RewriteRule ^mobile/([^/]+)/([^/]+)$ /mobile.php?page=$1&subject=$2 [QSA]
RewriteRule ^mobile/([^/]+)$ /mobile.php?page=$1 [QSA,L]

to give me: 给我:

/mobile/page/subject /移动/页/主题

/mobile/page /移动/页

I've tried changing [QSA,L] to [NC,L] and nothing. 我尝试将[QSA,L]更改为[NC,L],什么也没有。 Any ideas? 有任何想法吗? Any help is greatly appreciated! 任何帮助是极大的赞赏! :) Thank you in advance. :) 先感谢您。

This rule cause endless looping: 此规则导致无限循环:

RewriteRule ^([^/]+)$ /index.php?page=$1 [QSA]

You need to add before him some limitation RewriteCond. 您需要在他之前添加一些限制RewriteCond。 Here yours rewrite call stack: 这里是您的重写调用堆栈:

在此处输入图片说明

PS NEVER MIND, i forgot created mobile.php , and I gote rewrite loop, Sorry for that. PS从来没有想过 ,我忘记创建了mobile.php ,我重写了循环,很抱歉。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM