Vincenzo Lo Palo
Vincenzo Lo Palo

Reputation: 1381

mod rewrite url with two url parameters

I have this url:

http://localhost/listing-video.php?q=php+course+online&page=1

I need change it in this way:

http://localhost/php-course-online/1

I added in my .htaccess this code without success:

RewriteEngine On
RewriteRule ^([^/]*)/([^/]*)?$ listing-video.php?q=$1&page=$2 [L]

Any help it's really appreciated

Upvotes: 1

Views: 114

Answers (1)

anubhava
anubhava

Reputation: 784898

Your regex doesn't look correct.

Try this rule:

# replace - by +
RewriteRule ^([^-]*)-(.*)$ $1\+$2 [L]

# rewrite to /listing-video.php
RewriteRule ^videosearchengine/([^/-]+)/([^/-]+)/?$ listing-video.php?q=$1&page=$2 [L,QSA,NE]

This will rewrite to: /listing-video.php?q=php+course+online&page=1

Upvotes: 1

Related Questions