dc519 Posted January 26, 2008 Share Posted January 26, 2008 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 from 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 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? Below is the code for both index.php and login.php, note that I needed to remove two page breaks from each file--I don't think the phpfreaks posting engine liked this and therefore I removed them below. Index.php: <?php echo '<html>'; echo '<head>'; echo '<title>index.php</title>'; echo '</head>'; echo '<body>'; echo 'inside index.php'; echo '<a href="login.php">to login.php</a>'; echo '</body>'; echo '</html>'; ?> login.php: <?php echo '<html>'; echo '<head>'; echo '<title>login.php</title>'; echo '</head>'; echo '<body>'; echo 'inside login.php'; echo '<a href="index.php">back to index.php</a>'; echo '</body>'; echo '</html>'; ?> Quote Link to comment https://forums.phpfreaks.com/topic/87925-php-files-not-working-with-htaccess/ Share on other sites More sharing options...
sKunKbad Posted January 26, 2008 Share Posted January 26, 2008 There are some updates at the bottom of the article: Update (Jul 9, 04): Note that if you use the dispatcher.php mod_rewrite rules above, you should also add dispatcher.php to your DirectoryIndex setting. Update (Jul 13, 04): Also see this. You'll probably want to change one of the above lines to "RewriteRule . %{REQUEST_FILENAME}.php%{PATH_INFO} [L]". Maybe one of these will fix your issue. Quote Link to comment https://forums.phpfreaks.com/topic/87925-php-files-not-working-with-htaccess/#findComment-449869 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.