Mod rewrite - trailing slash "/" question

Hello,

Here is what my .htaccess contains:

Code: [Select]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^.* list.php
Now this is the code which is using the keyword “How-I-Met-Your-Mother” in the url http://www.dontwatchvideo.com/How-I-Met-Your-Mother/ to show the relevant videos based on the keyword. It is being done by sending the keyword “How-I-Met-Your-Mother” to a .php page (using $_Get) on my site to process the videos for this keyword.

But if I goto http://www.dontwatchvideo.com/How-I-Met-Your-Mother the page shows no videos. No keyword is passed to the $_Get paramater if the trailing slash “/” is not added to the end of the url.

Please tell me how to edit the line
Code: [Select]
RewriteRule ^.* list.php so that it works without trailing slash “/”

Please let me know.

Thnx

can anyone help me with this fast? pls

Your rule needs to be set up to pass the query information in via the URL or it won’t work. Something like this may help:

RewriteRule ^/([0-9a-z-]+)/?(.*) list.php?$1 [E=REDIRECT_TARGET:list.php]

The environment variable E=REDIRECT_TARGET may not be necessary, but try it with/without to see if it works.

um,

The problem you’re having is in not specifying the acceptable characters with your regex (you’re using what is known as “lazy regex” which I rail on about constantly). PLEASE learn some real regex (start with the tutorial linked in my signature if you have no other place to go) as there are MANY forms your regex CAN take to satisfy your requirement.

Shaggy,

Sorry but your code makes no sense to me. It says, USING APACHE 1.x (really?), start with one or more digits, lowercase letters and hyphens followed by an optional / followed by ANYTHING and redirect the pre-/ nonsense as the KEY in a valueless query string assigned to list.php. Does that make any sense to you?

Regards,

DK

Why would I have suggested it if it didn’t make sense? :slight_smile:

I have used this type of setup numerous times (although admittedly passing the URL in via a variable instead of as a generic query string parameter) but both can and do work via PHP.

What makes you think this is Apache 1.0 code?

What does it mean to you?[/indent]
What makes you think this is Apache 1.0 code?[indent]^/[/indent][/QUOTE]
Regards,

DK

You wouldn’t have but my interpretation of your code makes no sense to me … at all!

Not much I can do about that I’m afraid :slight_smile:

^/

Gee, thanks, that tells me everything I need to know.

Wouldn’t it be more helpful for others if you actually suggested an alternative that does work?

Shaggy,

No definition from you about what you think your code is saying?

My posts (and the sticky threads and the tutorial linked in my signature) are full of comments re the difference between Apache 1.x and Apache 2.x (and the impact on the start anchor use). If you don’t know the difference, use ^/? as both will accept that.

Regards,

DK