Jump to content

Simple rewrite problem


Stooney

Recommended Posts

I'm not very experience with mod_rewrite.  The following bit works fine on my dev server, but when used on my 1and1.com shared host account, I get Error 500 - Internal server error.  That problem is with the RewriteRule, as anything that is indeed a file (such as http://site.com/index.php?d=home) works fine.

 

I won't lie, the RewriteRule is basically copy pasted.  I will be looking into mod_rewrite a lot more in depth, but for now I'm just looking for a quick fix to get a live site running.

 

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php?d=$1 [L,QSA]

Link to comment
Share on other sites

Yes it's enabled.  After a couple emails back and fourth with 1and1 here's what they said:

 

As we checked your code we found out that the code you used in your

.htaccess is incorrect.

 

in response to this:

RewriteEngine on

RewriteCond %{REQUEST_FILENAME} !-f

RewriteRule ^(.*)$ index.php?d=$1 [L,QSA]

Link to comment
Share on other sites

Try a super simple rewrite.

 

 

Something like:

 

RewriteRule somepage\.html someotherpage.html

 

 

And see if it works.

 

 

If it does, try adding the rewrite cond with it.  If the rewrite cond makes it fail, that's it.  If not, it's the RR.  Can't just comment out the RR because that would cause an infinite loop.

Link to comment
Share on other sites

Alright, so I did what you said.  I changed my .htaccess (shown below).  It works on my dev server, but the live server (hosted by 1and1) gives a page not found error when attempting site.com/somepage.html

 

.htaccess

RewriteEngine on

RewriteCond %{REQUEST_FILENAME} !-f

RewriteRule somepage\.html someotherpage.html

 

So I'm guessing that would mean mod_rewrite is actually disabled?  They told me it's enabled and I can use it as I wish.

Link to comment
Share on other sites

That could just mean that someotherpage.html doesn't exist.

 

 

If mod rewrite weren't enabled, you would be getting a 500 error.

 

 

Try changing your rewrite to:

 

 

RewriteEngine on

RewriteCond %{SCRIPT_FILENAME} !-f

RewriteRule ^(.*) /index.php?d=$1 [L,QSA]

Link to comment
Share on other sites

I made sure someotherpage.html did exist, I made it to test with.  The following .htaccess file gives me a 500 error:

 

RewriteEngine on
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteRule ^(.*) index.php?d=$1 [L,QSA] 

 

I might just host my own site or get a different host.  I don't know what else I can change here, it works fine on my home server just not on live.

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.