Jump to content

.htaccess not working as intended, re: clean urls


dc519

Recommended Posts

I’m having some problems using an .htaccess file together with the .php files on my site.

 

Let me supply the details, my domain is seriesthree.com and I’m only working with two files so far, they are index.php and login.php. Each is quite barebones and only contains a line of text stating the name of the file and then a link to the other page.

 

Also, there is no index.htm or index.html in the directory or on my site whatsoever. Index.php and login.php are located in the root directory along with the .htaccess file.

 

My goal of this, as of yet small project, is to always strip the trailing file extensions, here, .php. from the files in order to create clean urls. I’m using the following instructions in my .htaccess file:

 

RewriteEngine On

RewriteCond %{REQUEST_FILENAME} !-f

RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule . /dispatcher.php [L]

 

I found this code as a result of a previous post at http://keithdevens.com/weblog/archive/2004/May/24/clean-urls.mod_rewrite.php

 

Note that if you simply go to http://seriesthree.com that you won’t see any file extension—in fact you are viewing my index.php page. But then, if you link to login.php, you will see the file extension and if you then link back to index.php, the homepage, you will also see the extension. This is my problem, what am I doing wrong in the .htaccess file that displays the file extension?

 

Here is the code for both index.php and login.php:

 

Index.php:

 

<?php
<html>
<head>
<title>index.php</title>
</head>
<body>inside index.php
<br><br>
<a href="login.php">to login.php</a>
</body>
</html>
?>

 

login.php:

 

<?php
<html>
<head>
<title>login.php</title>
</head>
<body>inside login.php
<br><br>
<a href="index.php">back to index.php</a>
</body>
</html>
?>

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.