Skip to main content
  1. About
  2. For Teams
Asked
Viewed 50k times
Part of PHP Collective
5

I'm setting my .htaccess file right now to use friendly urls (manually). But, when i go to the url the server shows me Error 404.

RewriteEngine on

RewriteCond %{SCRIPT_FILENAME} !-d  
RewriteCond %{SCRIPT_FILENAME} !-f  

Rewriterule ^register$ register.php 

I'm really sure that mod_rewrite is enabled because i see it when use phpinfo().

4 Answers 4

19

Even though mod-rewrite is enabled, by default it is not enabled for .htaccess files.

Hold Your Breath

  • Open xampp control panel
  • Stop Apache
  • Click the Config button on the Apache row, and select httpd.conf
  • In that file, search for something like xampp/htdocs">
  • A bit lower, you may see a line like this: # AllowOverride All. Remove the #, which is a comment
  • Alternately, search for AllowOverride All, make sure it is in the right section, and remove the comment #
  • Save the file
  • Restart Apache, say a prayer, cross your fingers and hold your breath
Sign up to request clarification or add additional context in comments.

1 Comment

Glad to hear it. It must have been the prayer. :) :) Thanks, see you next time!
2

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]

if we want to remove index.php form url .First we create a .htaccess file on root directory of project with out any extension. And add this code in this file and so remove the index.php Application/config/config.php

1 Comment

Thank you for this code snippet, which might provide some immediate help. A proper explanation would greatly improve its long-term value by showing why this is a good solution to the problem, and would make it more useful to future readers with other, similar questions. Please edit your answer to add some explanation, including the assumptions you've made.
1

This listing may be old but is still relevant so to make it a little more secure it is probably best to add a few lines.

Deny from all
Allow from 127.0.0.1 ::1 localhost
Allow from .htaccess

Also as a side note .htaccess files slow the speed of the server so it would be best to refer to xampp documentation for best practices.

Hope it helps.

Comments

0

Check in httpd.conf you tag, review this property

AllowOverride All

AllowOverride authorize use htaccess file.

Comments

Your Answer

Post as a guest

Required, but never shown

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.

Morty Proxy This is a proxified and sanitized view of the page, visit original site.