1

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

1 Answer 1

1

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

Sign up to request clarification or add additional context in comments.

9 Comments

Is it placed in DOCUMENT_ROOT/.htaccess?
yes in DOCUMENT_ROOT. I removed a slash before listing-video.php RewriteRule ^([^/-]+)/([^/-]+)/?$ listing-video.php?q=$1&page=$2 [L,QSA,NE] and I get php error: atal error: Call to a member function fetch_assoc() on a non-object
That error is from your php code. I suggest first your do print_r($_GET) to se what values you get there.
ok, I resolved php error, with your code, url works only so: videosearchengine/php+course+online/1 but I need so: videosearchengine/php-course-online/1
incredible, now Im getting this strange redirect localhost/C:/xampp/htdocs/videosearchengine/php+course-online/1
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.