Flatlyn
Flatlyn

Reputation: 2050

Apache Mod_ReWrite Suddenly Stopped Working

I had mod_rewrite set on my server to rewrite a url like the following

http://www.example.com/1

to

http://www.example.com/index.php?show=1

In order words a URL shortern. Everything was working fine when the system was running under a sub-domain on my development site, but now it just generates a Not Found error, although if I manually enter the url /index.php?show=1 it works fine.

So the only changes is the urls switching from

http://www.site.example.com

to

http://www.site.com

however it's still running on the same server and the same sub-folder inside public_html on the server just the new domain name has been pointed to that folder.

The folder it's stored in is /public_html/paste

The full .htaccess file running in the directory is

# Set Default File
DirectoryIndex index.php

# Turn ReWrite Engine On
RewriteEngine on

# Create Rule To Write URLs To Shorter Versions
RewriteRule /([a-z0-9]+) /index.php?show=$1

I can't enable RewriteLog as the hosting doesn't allow it for some reason.

Upvotes: 2

Views: 1131

Answers (2)

Chris Henry
Chris Henry

Reputation: 12010

It sounds like the AllowOverride directive is not properly set for that folder. In your Apache configuration, you should make sure that the Directory or Vhost you're using for the primary domain has the AllowOverride set to All

http://httpd.apache.org/docs/2.0/mod/core.html#allowoverride

Upvotes: 2

JohnKlehm
JohnKlehm

Reputation: 2398

You probably need to specify the RewriteBase directive.

http://httpd.apache.org/docs/current/mod/mod_rewrite.html#rewritebase

I'll also note that Options +FollowSymlinks would be good to have in there too in case you ever turn it off further up the config chain (rewrite wont work without it).

Upvotes: 1

Related Questions