I have the following rule in my .htaccess file. It works fine on my live site but on my localhost it sends me to
http://localhost/gandalf/play-video.php?vid=video
rather than
http://localhost/mysite/gandalf/play-video.php?vid=video
RewriteRule ^gandalf/play-video-([A-Za-z0-9-\']+)$ /gandalf/play-video.php?vid=$1 [R=302,L]
Can the rule be changed to work on both the live site and localhost? I’ve tried removing the leading slash on the target but that doesn’t work (I forget what it does! )
Erik_J
July 28, 2020, 12:00pm
2
Doesn’t it mean, as normally, “from the root directory” of the site?
It is a plain url isn’t it?
Hold on, I’ll try it and tell you what happens…
Update:
I get a 404 as it tries to send me to
http://www.domain.co.uk/services/users/storage/account/www/domain.co.uk/gandalf/play-video.php?vid=video
Url is http://www.domain.co.uk/gandalf/play-video-video
Erik_J
July 28, 2020, 12:35pm
4
That’s pretty amazing for a leading slash in the target:
/gandalf/play-video.php?
Does your .host file have the correct virtual site?
1 Like
That’s without the slash. With the slash works.
1 Like
igor_g
July 28, 2020, 4:03pm
6
Variant 1.
RewriteRule ^(([A-Za-z0-9-']+)\/)?gandalf/play-video-([A-Za-z0-9-']+)$ /$1gandalf/play-video.php?vid=$3 [R=302,L]
Variant 2.
Create virtual host with root directory mysite. Then you need no changes in .htaccess.
2 Likes
Gandalf
Closed
October 27, 2020, 11:03pm
7
This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.