Help rewriting /index.php to /index

leafypiggy

Manager of Pens and Office Supplies
Staff member
Messages
3,819
Reaction score
163
Points
63
Hey y'all,

I'm using mod_rewrite in apache, and I can't seem to get this code to work. FreeNode was unhelpful as usual, seeing as they're all full of themselves and think they know everything and are just plain a pain in the butt.

Anyways: Here's my code.

Mod_rewrite is enabled (a2enmod rewrite), and I'm logging it to /var/log/apache2/rewrite.log (at RewriteLogLevel 9):

Code:
Options +FollowSymLinks
Options +Indexes
RewriteEngine on
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteRule ^([^\.]+)$ $1.php [NC,L]

Nothing's in the log file.

Basically, that script should just take file.php, and make it just file. (in the browser.

Link is: http://bakon.neilhanlon.com/vizoxidy/index.php
 

espfutbol98

New Member
Messages
200
Reaction score
2
Points
0
Here's what I use on my site and it workes like a charm. It references /[whatever] to [whatever].php and if it can't find it, it shows, in this case, error.php
Code:
RewriteCond %{DOCUMENT_ROOT}/$1.php -f
RewriteRule ^/?(.*)$    $1.php 
RewriteRule ^/?error\.php - [L]
 
Last edited:

leafypiggy

Manager of Pens and Office Supplies
Staff member
Messages
3,819
Reaction score
163
Points
63
Still nothing.. Nothing in rewrite.log either... :(

Anyone else care to offer their opinion?
 

leafypiggy

Manager of Pens and Office Supplies
Staff member
Messages
3,819
Reaction score
163
Points
63
Doesn't work on an x10 server either.. so it's not my server that's the issue.
 

leafypiggy

Manager of Pens and Office Supplies
Staff member
Messages
3,819
Reaction score
163
Points
63
With the help of lemon-tree, I've figured it out.

Code:
DirectoryIndex index
Options +FollowSymLinks
RewriteEngine on
RewriteRule ^index.php$ /vizoxidy/index [R]
<FilesMatch index>
        ForceType application/x-httpd-php
</FilesMatch>

Copied index.php to index (and deleted index.php)

Then set it to force a particular MIME type to certain files.

Next, we redirected index.php to index.

Then we added a DocumentRoot.

And finally, I went to go rub it in #httpd's face.. but I forgot I was banned from that channel. =/
 

leafypiggy

Manager of Pens and Office Supplies
Staff member
Messages
3,819
Reaction score
163
Points
63
I'd heard that mentioned in #httpd yesterday...

Didn't work, but lemon-tree and I diagnosed that it was because I had AllowOverride None set in my vhost.. so.. I'll try it.

Edit:

Works! Much simpler than what I did. :)
 
Last edited:
Top