Pregunta

I use the following rule

RewriteRule ^([\w]+)/?([\w]+)? index.php?action=$1

for rewriting

www.mysite.com/123

to

www.mysite.com/index.php?action=123

This needs to remain like this, but there are cases where I also need to rewrite

www.mysite.com/123/abc

to

www.mysite.com/index.php?action=123&example=abc

How can I achieve this? Thanks!

¿Fue útil?

Solución

Enable mod_rewrite and .htaccess through httpd.conf and then put this code in your .htaccess under DOCUMENT_ROOT directory:

Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /

RewriteRule ^([^/]+)/([^/]+)/?$ index.php?action=$1&example=$2 [L,QSA]

RewriteRule ^([^/]+)/?$ index.php?action=$1 [L,QSA]
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top