Jump to content

.htaccess mod rewrite problems


aebstract

Recommended Posts

RewriteEngine On

RewriteBase /

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([A-Z]+)/$ /index.php?page=$1 [NC,L]
RewriteRule ^([A-Z]+)/([0-9]+)/$ /index.php?page=$1&var1=$2 [NC,L]

 

www.berryequipment.net

 

If you click, for example, "featured product" you'll see this url and it works:

http://www.berryequipment.net/index.php?page=featured

though if you go to

http://www.berryequipment.net/featured/

you get a forbidden 403 error.. does anyone have any reasoning for why I'm coming up with this error?

Link to comment
Share on other sites

Do you have a "featured" directory within your root? I know this seems like a basic question, but I want to be sure I know your structure. Based on the response of the browser, my guess is that you actually have a "featured" path in your web root which causes your RewriteCond to not be met, therefore, it never gets rewritten. Compare it with this: if I put http://www.berryequipment.net/index.php?page=asdf and http://www.berryequipment.net/asdf/, I get the same content. Now, your styles are not picked up in the second, but that is most likely another issue entirely. the rewrite, though, does work.

Link to comment
Share on other sites

Here is my problem I am now facing:

http://berryequipment.net/order/PH/

should be something similar to:

http://berryequipment.net/index.php?page=order&sheet=PH

 

The variable NAME isn't that important, its set to var1 in the code and I can change the script so it matches up with var1 instead of sheet, but why am I getting a 404 error on http://berryequipment.net/order/PH/ but I don't get one with http://berryequipment.net/order/ ?

 

 

 

 

EDIT: Changed the 0-9 to A-Z and it is now working. ;)

Link to comment
Share on other sites

I don't think I really need a new topic for this, so I'll continue under my already on-going topic.

Right now I am using this:

 

RewriteEngine On

RewriteBase /

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([[:alnum:]_]+)/$ /index.php?page=$1 [NC,L]
RewriteRule ^([[:alnum:]_]+)/([[:alnum:]]+)/$ /index.php?page=$1&var1=$2 [NC,L]

 

Which seems to be working for about everything. Here is the problem I have run in to and can't find a workaround for: Before I switched over to using this, I would have a url like index.php?page=blabla#line60 Which would take you to the "line60" spot on the page, wherever I set that within the page. I can I do something like this, with the clean urls?

Link to comment
Share on other sites

I can I do something like this, with the clean urls?

 

I don't know that you need to do that with mod_rewrite. It's the browser that interprets the # and anchor following, so you should be able to link to your clean URL with the anchor added:

 

index.php/blahblah/#line60

Link to comment
Share on other sites

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.