I want to change:
domain/link to domain/index.php?q=link
and
domain/notice/20151212/title-with-a to domain/index.php?q=notice&date=20151212&title=Title-with-a
with this .htaccess file:
RewriteEngine On
RewriteRule ^([a-zA-Z-]+)$ index.php?q=$1 [L]
RewriteRule ^notice/([0-9]+)/([A-Za-z0-9_-]+)$ index.php?q=notice&date=$1&title=$2 [L]
If i enter into domain/link or domain/link2
, goes well but if i try to enter to domain/notice/20151212/title-with-a
, I can't because it cant get CSS, image, JS files (tries to get domain/notice/20151212/js/theme.js
when the file is in domain/js/theme.js
) but i can enter without problems by the URL:
domain/index.php?q=notice&date=20151212&title=Title-with-a
What am I doing wrong?
I check this regex on http://htaccess.mwl.be/ and i think the htaccess file is right.
Thank you.
try to do this
RewriteEngine On
RewriteRule ^notice/([^/]+)/([^/]+)/$ index.php?q=notice&date=$1&title=$2 [L]
RewriteRule ^([a-zA-Z-]+)$ index.php?q=$1 [L]
and try to revert order like here
RewriteEngine On
RewriteRule ^notice/([0-9]+)/([A-Za-z0-9_-]+)$ index.php?q=notice&date=$1&title=$2 [L]
RewriteRule ^([a-zA-Z-]+)$ index.php?q=$1 [L]
EDIT add [L] at the end of second line and try my url, it works
http://lab.maurosala.it/notice/a/b/
if you don't want the / at the end of url use this
RewriteRule ^notice/([^/]+)/([^/]+) notice.php?q=notice&date=$1&title=$2 [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.