简体   繁体   中英

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:

normal .htaccess config (works)

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:

desired additional config (not working - throws 500 errors)

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. 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. Here yours rewrite call stack:

在此处输入图片说明

PS NEVER MIND, i forgot created mobile.php , and I gote rewrite loop, Sorry for that.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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