.htaccess not working on localhost with XAMPP

前端 未结 9 1383
北荒
北荒 2020-11-27 20:49

i m using XAMPP but i m not able to use .htaccess file at local host. i m trying so many times.. Online working good. but local host showing [The requested URL was n

相关标签:
9条回答
  • 2020-11-27 21:22

    I had a similar problem. But the problem was in the file name '.htaccess', because the Windows doesn't let the file's name begin with a ".", the solution was rename the file with a CMD command. "rename c:\xampp\htdocs\htaccess.txt .htaccess"

    0 讨论(0)
  • 2020-11-27 21:23

    For windows user, make sure to closely look at this section.

    RewriteRule ^properties$ /property_available.php/$1 [NC,QSA]
    

    As said in Apache documentation :

    The mod_rewrite module uses a rule-based rewriting engine, based on a PCRE regular-expression parser, to rewrite requested URLs on the fly.

    So ^properties$ means Apache will only look for URL that has exact match with properties. You might want to try this code.

    RewriteRule properties /property_available.php/$1 [NC,QSA]
    

    So Apache will see the URL that has properties and rewrite it to /property_available.php/

    0 讨论(0)
  • 2020-11-27 21:26

    Try

    <IfModule mod_rewrite.so>
    ...
    ...
    ...
    </IfModule>
    

    instead of <IfModule mod_rewrite.c>

    0 讨论(0)
  • 2020-11-27 21:26

    for xampp vm on MacOS capitan, high sierra, MacOS Mojave (10.12+), you can follow these

    1. mount /opt/lampp
    2. explore the folder
    3. open terminal from the folder
    4. cd to `htdocs`>yourapp (ex: techaz.co)
    5. vim .htaccess
    6. paste your .htaccess content (that is suggested on options-permalink.php)
    

    0 讨论(0)
  • 2020-11-27 21:32

    Without seeing your system it's hard to tell what's wrong but try the following (comment answer if these didn't work WITH log error messages)

    [STOP your Apache server instance. Ensure it's not running!]

    1) move apache server/install to a folder that has no long file names and spaces

    2) check httpd.conf in install\conf folder and look for AccessFileName. If it's .htaccess change it to a file name windows accepts (e.g. conf.htaccess)

    3) double-check that your htaccess file gets read: add some uninterpretable garbage to it and start server: you should get an Error 500. If you don't, file is not getting read, re-visit httpd.conf file (if that looks OK, check if this is the only file which defines htaccess and it's location and it does at one place -within the file- only; also check if both httpd.conf and htaccess files are accessible: not encrypted, file access rights are not limited, drive/path available -and no long folder path and file names-)
    STOP Apache again, then go on:
    4) If you have IIS too on your system, stop it (uninstall it too if you can) from services.msc

    5) Add the following to the top of your valid htaccess file:
    RewriteEngine On
    RewriteLog "/path/logs/rewrite.log" #make sure path is there!
    RewriteLogLevel 9

    6) Empty your [apache]\logs folder (if you use another folder, then that one :)

    7) Check the following entries are set and correct:
    Action application/x-httpd-php "c:/your-php5-path/php-cgi.exe"
    LoadModule php5_module "c:/your-php5-path/php5apache2.dll"
    LoadModule rewrite_module modules/mod_rewrite.so
    Avoid long path names and spaces in folder names for phpX install too!

    8) START apache server

    You can do all the steps above or go one-by-one, your call. But at the end of the day make sure you tried everything above!
    If system still blows up and you can't fix it, copy&paste error message(s) from log folder for further assistance

    0 讨论(0)
  • 2020-11-27 21:35

    I've setup xampp for my localhost as well, I've not done anything with the files created by xampp during or after setup.

    But in the '.htaccess' file, make sure you've set it to something like this. Works for me, and this should not make any difference for you.

    RewriteEngine On
    RewriteRule ^filename/?$ filename.html
    

    Change .html to whatever format you're using.

    Make sure your install is clean, and just make the .htaccess file. Also remember to put one .htaccess file for each directory (don't really know if you can use ONE file for all folders, but to be safe, just do this and it will always work.

    0 讨论(0)
提交回复
热议问题