.htaccess file 404 error with parallel plesk server - .htaccess

I have my .htaccess file working in localhost. But its not working if i upload it in server. It throws me 404 error.
I am using Parallel Plesk 11.0.9 and i can't find conf file for the same on that. If anyone has any idea how to fix it or any workaround for url rewriting would be great help.
Anyway here's the code in htaccess:
RewriteEngine on
RewriteRule ^store/living/Hutches-Armoires-Side-tables-Coffee-tables-Entertainment-centers? store.php?store=Living
RewriteRule ^store/dining/sideboards-buffets-chairs-benches-Dining-table$ store.php?store=Dining
RewriteRule ^store/working/Bookshelves-Study-tables$ store.php?store=Working
RewriteRule ^store/accessories/Boxes-Photo-Frames-Mirror-Frames-Block-Stamps-and-Book-stands$ store.php?store=Accessories
RewriteRule ^store/hallway/Console-tables-Armoires$ store.php?store=Hallway
RewriteRule ^store/sleeping/Bed-Frames-Night-Stands-Dressers-Mirror-framesBed-Linens-Canopies-Curtains$ store.php?store=Sleeping

You may need to wrap your rewrite rules with:
<IfModule mod_rewrite.c>
...
</IfModule>
...probably a good idea anyway.
Or you could try putting your rules into a vhost.conf file in the conf directory immediately below the location of your httpdocs directory. For example on a Centos machine the web root might be
/var/www/vhosts/domain.com/httpdocs
and you should have a:
/var/www/vhosts/domain.com/conf
directory, this will contain a set of pregenerated Apache config files that Plesk creates. If there isn't already create a vhost.conf and add your rules between a set of
<Directory /var/www/vhosts/domain.com/httpdocs/ >
... your rules ...
</Directory>
Once you've created the vhost.conf file you will need to tell plesk about it with
/usr/local/psa/admin/sbin/httpdmng --reconfigure-domain domain.com
If you still can't get it to work you can add a log for mod_rewrite, see this relevant SO answer for details

Is your Plesk running IIS and supporting PHP via FastCGI or ISAPI? If that is the case, check whether URL Rewrite is installed and follow this guide to translate htaccess (for apache) into web.config (for IIS)

Related

Symfony 3.4 located in subdirecory, remove web/ from url

I have 3 php apps on one server. I cant modify any apache files. Haw can I set .htaccess to remove web/ folder from url?
192.168.45.54/app1/
192.168.45.54/app2/
192.168.45.54/app3/web - I want to change it to 192.168.45.54/app3/
On adress 192.168.45.54/app3/web/ everythink is working fine. But haw can I remove web/ from url?
I created .htaccess files:
RewriteEngine On
RewriteBase /app3
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ web/$1 [QSA,L]
But when I go to 192.168.45.54/app3/ in symfony log files I have fallowing error:
No route found for "GET /app3/"
I use Symfony in 3.4 version. I think that problem is in .htaccess located in /web directory... Haw to configure .htaccess corectly?
I can't create virtual host becouse I haven't access to the server...
You need to make the web/ directory the document root of your website. If you have direct access to the webserver’s virtual host configuration, change the document root to the following line and restart Apache:
DocumentRoot /path/to/symfony/web/
If you can’t modify the virtual host file directly, your hosting provider will usually give you the possibility to modify the document root through some kind of online tool.

.htaccess not working on localhost with XAMPP

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 not found on this server]
My root folder is real
localhost/acre/real/property_available.php
localhost/acre/real/properties
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /acre/real/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^properties$ /property_available.php/$1 [NC,QSA]
</IfModule>
Please
Just had a similar issue
Resolved it by checking in httpd.conf
# AllowOverride controls what directives may be placed in .htaccess files.
# It can be "All", "None", or any combination of the keywords:
# Options FileInfo AuthConfig Limit
#
AllowOverride All <--- make sure this is not set to "None"
It is worth bearing in mind I tried (from Mark's answer) the "put garbage in the .htaccess" which did give a server error - but even though it was being read, it wasn't being acted on due to no overrides allowed.
In conf/extra/httpd-vhosts.conf, add the line AllowOverride All for all the websites that you are having problem with
<VirtualHost example.site:80>
# rest of the stuff
<Directory "c:\Projects\example.site">
Require all granted
AllowOverride All <-----This line is required
</Directory>
</VirtualHost>
Try
<IfModule mod_rewrite.so>
...
...
...
</IfModule>
instead of <IfModule mod_rewrite.c>
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
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"
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)
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/
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.
Edit the .htaccess file, so the first line reads 'Test.':
Test.
Set the default handler
DirectoryIndex index.php index.html index.htm
...

htaccess rewrite working offline on WAMP but not online on linux host

I'm just going to explain my problem here :
http://mysite.com/movie/20000
should be rewritten to
http://mysite.com/movie.php?id=20000
my htaccess file :
Options +FollowSymlinks
RewriteEngine On
RewriteRule ^movie/([0-9]+)$ movie.php?id=$1
On my localhost WAMP installation this works fine, but when I put it online on my linux host it doesn't completely work. It does go to the movie.php page, but it seems it gives no GET parameter id.
Edit :
if I use
Options +FollowSymlinks
RewriteEngine On
RewriteRule ^movie([0-9]+)$ movie.php?id=$1
then
http://mysite.com/movie20000
Goes to the correct page, but I would like /movie/20000 and not just /movie20000
It also seems that my host automatically rewrites a visit to mysite.com/movie to mysite.com/movie.php
After searching for a long time, and pulling some of my lovely hair out I found the solution.
I just added
Options -MultiViews
to my htaccess file and that fixed it.
Why? Because .php was being added to urls without an extension, which I really did not need.
This should work.
RewriteRule ^movie/([0-9]+)$ http://mysite.com/movie.php?id=$1 [NC,L]
Don't forget the [NC, L] it means Case insensitive, last rule... If you don't, it will continue to process through your htaccess rules, maybe triggering other ones.
Still, the stuff below is good advice.... :)
Check to see if the Rewrite module is loading with apache. Look for this line in the httpd.conf file:
LoadModule rewrite_module modules/mod_rewrite.so
Check to see if your apache config allows for .htaccess files for your system or in the virtual host definition.
Also, test with a simpler rewrite catch all and test that alone to see if it's working at all like this (get rid of everything else in your htaccess file to limit the test):
RewriteEngine On
RewriteRule ^(.*)$ http://www.google.com [L,R=301]
Any request to your site should go to google if the configuration for apache is correctly set.

Redirect links to correct directory

We have on our site hundreds of links that point to:
/about/about/filename.html
But we need them to go to:
/about/filename.html
Is there a way to point them to the correct directory?
We are running on a Linux server and the site is build with Joomla Version 1.5.10 and there is ARTIO JoomSEF 3.8.2 running on it.
Thanks
Assuming you're using the Apache webserver, you can use mod_rewrite, specifically the RewriteRule directive:
RewriteRule /about/about/(.+)$ /about/$1 [R=301]
Place this rule in your httpd.conf file in the <VirtualHost> context for the site in question, or in a .htaccess file in the site's DocumentRoot.
This rule will create a 301 Permanent redirect for requests to any path under /about/about/ to the same path under /about/. e.g., /about/about/filename.html will redirect to /about/filename.html

.htaccess not working on my server

I'm working on my project and now I want to transfer it from my localhost to server. Everything seems to work fine, but .htaccess doesn't work.
The server should be suporting mod_rewrite and print_r(apache_get_modules()); shows mod_rewrite running.
But still, when I type myaddress.com/contact, it shows error 404.
Here is the .htaccess file, but it should be fine, since it runs on my localhost:
RewriteEngine on
RewriteRule ^adminator/?$ adminator/login.php [L]
RewriteRule ^([^/\.]+)/([^/\.]+)/?$ index.php?page=$1&detail=$2 [L]
RewriteRule ^([^/\.]+)/?$ index.php?page=$1 [L]
Do you have any idea?
Thanks, Mike.
Does the server allow .htaccess? It doesn't really have to.
Try other directives, ask your hosting provider, or check the configuration yourself if possible.
I tried testing your rules they should be fine on urls such as: http://myhost.com/test1 and http://myhost.com/test1/test2 result in requesting url: index.php?page=test1 and index.php?page=test1&detail=test2
So the problem is not your rules, it is your server setup somewhere. As Mewp said check your Apache config file, look for AllowOverride which should be enabled for .htaccess files to overriding default settings.
Ok, fixed it .. deep in the hostings settings, there was an option to activate it .. but I found it after 4 hours of looking around .. :P

Resources