video/watch.php?pid=320 --> watch:320

New to mod_rewrite? This is a good place to start.

Postby nypd » Tue Oct 23, 2007 8:35 pm

I will then, but, is it possibel to do this rewrite as i mentioned before:

/watch.php?pid=ID -> /ID
nypd
 
Posts: 48
Joined: Wed Aug 01, 2007 2:20 am

Postby richardk » Wed Oct 24, 2007 1:16 pm

/watch.php?pid=ID -> /ID

Don't you mean /wraps/video/watch.php?pid=ID to /video/ID? That's what this does:
Code: Select all
RewriteCond %{ENV:REDIRECT_STATUS} ^$
RewriteCond %{QUERY_STRING} ^(.*&)?pid=([^&]+)(&.*)?$ [NC]
RewriteRule ^wraps/video/watch\.php$ /watch/%2/? [R=301,L]


If it's /video/watch.php not /wraps/video/watch.php, remove "wraps/".
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

Postby nypd » Fri Oct 26, 2007 9:56 pm

This is strange. Id does not work like that - 404 error =, I have tryed everything with this last suggestion, but no success.

Now, the real path is /wraps/video/watch.php
However i have on re-write concerning video already that i need:

Code: Select all
RewriteRule ^video$ /video/$1 [R]^
RewriteRule ^video/?(.+)$ /wraps/video/$1 [NC]^
RewriteRule ^video?(.+)$ /wraps/video/$1 [NC]^



because i want to hide the wraps part. Now your previous code works like a charm. but it is for:

domain.com/watch/ID and when i replace the watch part in it with video i guess some conflict appears, with the code i have mentioned. I am sory that this thread got out of hand... but i am stuck...
nypd
 
Posts: 48
Joined: Wed Aug 01, 2007 2:20 am

Postby richardk » Sat Oct 27, 2007 4:40 pm

Post your full .htaccess file.
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

Postby nypd » Sat Oct 27, 2007 11:54 pm

Code: Select all
RewriteEngine on^
Options +FollowSymLinks^
^
RewriteRule ^video$ /video/$1 [R]^
RewriteRule ^video/?(.+)$ /wraps/video/$1 [NC]^
RewriteRule ^video?(.+)$ /wraps/video/$1 [NC]^
^
^
^
RewriteRule ^ewatch:?([^/]+)v([^/]+)$ /wraps/video/medias/uservids/$1/$2 [QSA]^
^
^
^
RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]^
RewriteRule ^(.*)$ http://%1/$1 [R=301,L]^
^
^
^
php_value register_globals off^
php_value upload_max_filesize 100M^
php_value post_max_size 100M^
php_value output_buffering on^
php_value max_execution_time 6000^
php_value max_input_time 6000 ^
php_value session.gc_maxlifetime 14400^
php_value memory_limit 210M^
php_value file_uploads On^
#php_flag display_errors On^
#php_value error_reporting E_ALL^
#php_value display_errors 1

nypd
 
Posts: 48
Joined: Wed Aug 01, 2007 2:20 am

Postby richardk » Sun Oct 28, 2007 10:00 am

Try
Code: Select all
Options +FollowSymLinks

RewriteEngine On

RewriteRule ^video$ /video/ [R=301,L]

RewriteCond %{ENV:REDIRECT_STATUS} ^$
RewriteCond %{QUERY_STRING} ^(.*&)?pid=([^&]+)(&.*)?$ [NC]
RewriteRule ^(wraps/)?video/watch\.php$ /video/%2/? [R=301,L]

RewriteCond %{DOCUMENT_ROOT}/wraps%{REQUEST_URI} !-f
RewriteCond %{DOCUMENT_ROOT}/wraps%{REQUEST_URI} !-d
RewriteRule ^video/([^/]+)/?$ /wraps/video/watch.php?pid=$1 [QSA,L]

RewriteRule ^(video/.*)$ /wraps/$1 [QSA,L]
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

Postby nypd » Thu Nov 01, 2007 4:07 pm

HEEeeyyyy that works.

There is one thing i noticed though. It redirects to:

domain.com/video/ID/ (which does not wok properly. It does, but it does not fetch the /wraps/video part properly, and does not load the video. However - this is fixable)

domain.com/video/ID (works like a charm)


So as i see, i just have to use:
Code: Select all
RewriteRule ^(wraps/)?video/watch\.php$ /video/%2? [R=301,L]


instead of:
Code: Select all
RewriteRule ^(wraps/)?video/watch\.php$ /video/%2/? [R=301,L]



I tested it and i did not observe any errors with anything.
Last edited by nypd on Thu Nov 01, 2007 4:19 pm, edited 1 time in total.
nypd
 
Posts: 48
Joined: Wed Aug 01, 2007 2:20 am

Postby richardk » Thu Nov 01, 2007 4:17 pm

Replace
Code: Select all
/video/%2/?

with
Code: Select all
/video/%2?
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

Postby nypd » Thu Nov 01, 2007 4:19 pm

oh you are fast. :)
nypd
 
Posts: 48
Joined: Wed Aug 01, 2007 2:20 am

Postby nypd » Thu Nov 01, 2007 4:20 pm

richardk i want to express how i am grateful that you have helped me with this one. THANKS A LOT !!!!!!!
nypd
 
Posts: 48
Joined: Wed Aug 01, 2007 2:20 am

PreviousNext

Return to Beginner's Corner

Who is online

Users browsing this forum: Majestic-12 [Bot] and 4 guests

cron