Jump to content

RewriteRule not working - trailing slash & another problem


Recommended Posts

Hi!  Please help!

 

I have two odd problems with my RewriteRules which I just do not seem to be able to resolve:

 

PROBLEM 1:

 

I want to add a trailing slash to a url such as test/1234 (therefore rewriting it to test/1234/).  My RewriteRule rule is:

 

RewriteRule ^(.*)([0-9]{4})$ $1$2/ [R]

 

but, the last slash in the rule is currently being ignored.  However, the following:

 

RewriteRule ^(.*)([0-9]{4})$ $1$2// [R]

 

results in test/1234// using the above exmaple.  Why is this?

 

PROBLEM 2:

 

Why does (a) below work, but (b) below not work?  I would like to use (b).

 

(a) RewriteRule ^foo-bar/([A-Za-z]+)/$ foobar.php?type=$1 [L] - working

(b) RewriteRule ^foobar/([A-Za-z]+)/$ foobar.php?type=$1 [L] - not working

 

The only difference is the hyphen in (a).

 

TIA

It would be a better idea if you provide your dynamic URL and static URL you want it to be.

 

RewriteRule ^([a-zA-Z]+)/([0-9]+){4}/$ NYNAMIC-URL

 

For (a), it will work only if you goes to http://domain.tld/foo-bar/ASDAS/

as for (b), it's http://domain.tld/foobar/ASDASD/

 

Take note of the "-".

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.