PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Monday, February 14, 2022

[FIXED] .htaccess not working on localhost

 February 14, 2022     .htaccess, localhost, mamp     No comments   

Issue

My completed code in my only .htaccess file:

Options FollowSymLinks
RewriteEngine On
RewriteBase /

RewriteRule blue-world.pl/([a-z]+)(?:/([a-z]+))? index.php?nav=$1#$2

I need to redirect blue-world.pl/name/name2 to blue-world.pl?nav=name#name2. How to do this to make it working BOTH: localhost and server.

When in MAMP i try to type: localhost/scregal.blue-world.pl/title i see:

The requested URL /scregal.blue-world.pl/title was not found on this server.

Below is my file hierarchy in localhost:

scregal.blue-world.pl
    - .htaccess
    - index.php -> var_dump($_GET)

In the httpd.conf there are following lines:

LoadModule rewrite_module modules/mod_rewrite.so

AllowOverride All

Solution

You can use this rule:

Options FollowSymLinks
RewriteEngine On

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]+)(?:/([^/]+))?/?$ index.php?nav=$1#$2 [L,QSA,NC]


Answered By - anubhava
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing