简体   繁体   中英

Pretty URL multilevel

I just begun trying to get pretty URLS to work and I have never worked with them before. I got it to work if it only on 'directory' like example.com/first but when i try to with another 'sub directory' got promlem (exaple.com/first/second)

It's the two at the bottom that doesn't work.

Options +FollowSymLinks
RewriteEngine On

RewriteCond %{SCRIPT_FILENAME} !-d
RewriteCond %{SCRIPT_FILENAME} !-f

RewriteRule ^([a-zA-Z0-9]+)/$ index.php?page=$1 #works
RewriteRule ^([a-zA-Z0-9]+)$ index.php?page=$1 #works

RewriteRule ^partier/([a-zA-Z0-9]+)/$ index.php?page=partier&parti=$2 #Don't work
RewriteRule ^partier/([a-zA-Z0-9]+)$ index.php?page=partier&parti=$2 #don't work
#www.example.com/partier/[your choice]/ --> www.example.com/index.php?page=partier&parti=[Your choice]

Use that:

Options +FollowSymLinks
RewriteEngine On

# skip all files and directories from rewrite rules below
RewriteCond %{REQUEST_FILENAME} -d [OR]
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule ^ - [L]

RewriteRule ^([a-z0-9]+)/?$ index.php?page=$1 [NC,L]
RewriteRule ^partier/([a-z0-9]+)/?$ index.php?page=partier&parti=$1 [NC,L]

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