0

Hi,

Please help me work out this mod-rewrite issue while trying to make my urls SEF.

RewriteEngine On
Options +FollowSymLinks

# Browse Category
RewriteRule ^category/[!/.]*([A-Za-z]+)/?$ /browse.php?cat=$1    [NC,L]

# View Item
RewriteRule ^view/([0-9]+)/([a-zA-Z0-9-]+)$ /view.php?item_id=$1&sef=$2 [NC]

This is my current .htacess.

The browse category rule is working ok
converting - http://localhost/browse.php?cat=people
into - http://localhost/category/people

the view item is giving a 404
trying to convert - http://localhost/view.php?item_id=28&sef=2009-bristol-blenheim-in-west-yorkshire
into - http://localhost/view/28/2009-bristol-blenheim-in-west-yorkshire

2
Contributors
10
Replies
14
Views
4 Years
Discussion Span
Last Post by vlowe
0

Strange. I can confirm that the rules work correctly for me, which would suggest it's a server config issue, rather than a problem with the rules themselves.

I had to disable MultiViews to get the rewrite to pass the parameters through, but even without that, it wasn't returning a 404.

You don't happen to have a symbolic link related to view at all do you?

0

added Options -Multiviews and is now working :)

thank you very much

0

another quick rewrite question..

can i add another Rewrite rule which will turn my basic /home.php, /sign-up.php into just /home , /sign-up (dropping the .php)

which will not interfere with my current rules?

0

Funnily enough, if you had MultiViews enabled, that would have already worked, although it'd be exploiting the functionality in a way it's perhaps not meant to be used.

MultiViews looks for a file / directory that is similar to the URL requested if a specific match isn't found.

Alternatively, you could try:

RewriteRule ^(.*)/$ /$1.php

Edited by blocblue

0

makes sense but i tried it as follows

`

RewriteEngine On
Options +FollowSymLinks
Options -Multiviews

RewriteRule ^(.*)/$ /$1.php

# Browse Category
RewriteRule ^category/[!/.]*([A-Za-z]+)/?$ /browse.php?cat=$1    [NC,L]

# View Item
RewriteRule ^view/([0-9]+)/([a-zA-Z0-9-]+)$ /view.php?item_id=$1&sef=$2 [NC]

getting

Not Found

The requested URL /home was not found on this server.

Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.

`

0

Remove the trailing slash in the RewriteRule and probably best to add a check that the request isn't for a physical file or directory:

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /$1.php

And you may find the rule needs to be the last RewriteRule to prevent conflict with the two aforementioned.

Edited by blocblue

0

thought so, but i tried that and i get ISE

Internal Server Error

The server encountered an internal error or misconfiguration and was unable to complete your request.

Please contact the server administrator and inform them of the time the error occurred, and anything you might have done that may have caused the error.

More information about this error may be available in the server error log.

0

Did you try the changes before I updated my last post?

Post what your .htaccess file looks like now...

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.