Status
Not open for further replies.

fdls

Active Member
1,588
2010
203
50
Hello

I have got the following mod_rewrite for my site.

Code:
RewriteEngine On
RewriteRule ^index\.html$ /index.php [L]
RewriteRule ^([^/]*)\.html$ /videos/watch.php?id=135&video=$1 [L]

The current url is
Code:
http://domain.com/videos/watch.php?id=130&video=My-Ride-Rules-S01E06-HDTV-XviD-CRiMSON-

I want it to be as
Code:
http://domain.com/My-Ride-Rules-S01E06-HDTV-XviD-CRiMSON-.html

Can someone guide me in fixing up the id=135 as it has to apply to all the ID's in the site.

Thanks <3
 
Last edited:
4 comments
Use this one:

PHP:
RewriteEngine On
RewriteRule ^index\.html$ index.php [L]
RewriteRule ^([^/]*)$ videos/watch.php?id=130&video=$1 [L]
It will work as you wanted

That will work for:

http://domain.com/videos/watch.php?id=130&video=My-Ride-Rules-S01E06-HDTV-XviD-CRiMSON-
http://domain.com/My-Ride-Rules-S01E06-HDTV-XviD-CRiMSON-

Edit:

Just saw that you want with ids too, so this will work with id's:

PHP:
RewriteEngine On
RewriteRule ^index\.html$ index.php [L]
RewriteRule ^([0-9]{4})-([^/]*)$ videos/watch.php?id=$1&video=$2 [L]

This will make the following url:

http://domain.com/130-My-Ride-Rules-S01E06-HDTV-XviD-CRiMSON-

To:

http://domain.com/videos/watch.php?id=130&video=My-Ride-Rules-S01E06-HDTV-XviD-CRiMSON-

If you want without id, then you need to edit the script you are using and check for the tile in db with special chars removed
 
Use this one:

PHP:
RewriteEngine On
RewriteRule ^index\.html$ /index.php [L]
RewriteRule ^([^/]*)$ /videos/watch.php?id=130&video=$1 [L]

It will work as you wanted

But isn't that going to replace only for the 130th ID ? .html is also required at the end
 
But isn't that going to replace only for the 130th ID ? .html is also required at the end
Check the above reply

If you want .html at the end then:

PHP:
RewriteEngine On
RewriteRule ^index\.html$ index.php [L]
RewriteRule ^([0-9]{4})-([^/]*).html$ videos/watch.php?id=$1&video=$2 [L]

Works the same way as above just add .html at teh endz
 
Check the above reply

If you want .html at the end then:

PHP:
RewriteEngine On
RewriteRule ^index\.html$ index.php [L]
RewriteRule ^([0-9]{4})-([^/]*).html$ videos/watch.php?id=$1&video=$2 [L]

Works the same way as above just add .html at teh endz

Thanks soft2050.

I knew that way. But the thing is I didn't want the ID to interfere and now I realized script needs to be fixed to get it removed. Anyways thanks for helping mate :)

Add this above code finally.
 
Status
Not open for further replies.
Back
Top