Can't access to web site after enabling mod_rewrite - linux

I activated mod_rewrite on my dedicated server : Centos 5.5, after that if I placed any .htaccess in any web site, i can't access the web site from http://site.com/, I have to specify index file, http://site.com/index.php
for example :
I have this web site http://www.floupie.com, the home file is located in http://www.floupie.com/cgi-bin/index.cgi
and I created an .htaccess rule to access it automaticly, but not working :
RewriteEngine on
RewriteRule ^$ /cgi-bin/index.cgi [L]
I have this problem with all web site in the server.
Help Please
Thanks in advance,

Restart the apache server. So that your mod_rewrite work

Related

How to show a content of one website in another website?

I have a website for example: https://test1.com, and a page on that website https://test1.com/show-content.
I want that page to display the content from another website, for example https://test2.com/show-different-content.
I know I can do it with PHP and file_get_contents, but I'm trying to do it with .htaccess, since I understand it can be possible. I've looked through all the SO questions I found regarding that, but I found no clear solution.
What I have tried in .htaccess is the following:
<IfModule mod_rewrite.c>=
RewriteEngine On
RewriteRule ^show-content$ https://test2.com/show-different-content [P]
</IfModule>
What am I doing wrong? Or am trying to do something that is not possible?
You have two options for this if the owner of that second site actually grants permission to proxy his sites content. You can use the proxy module available for the apache http server.
Either direct:
ProxyPass /show-content/ https://test2.com/show-different-content/
ProxyPassReverse /show-content/ https://test2.com/show-different-content/
Or embedded in the rewriting module:
RewriteEngine On
RewriteRule ^/?show-content/(.*)$ https://test2.com/show-different-content/$1 [P]
Obviously the proxy module needs to be loaded and activated inside the http server.

Azure Web App - Linux/Laravel : Point domain to folder

I just started using Azure and created a Linux web app.
I followed the domain DNS tutorial and setup my domain :
https://learn.microsoft.com/en-us/azure/app-service-web/app-service-web-tutorial-custom-domain
I used the custom domain - text type
test.com does not point to the folder /site/wwwroot on the app.
I placed the site folder in /wwwroot
However, in laravel - the actual site is in /sitefolder/public
How do I point to this folder?
Thanks
It has nothing to do with DNS. What you need to do is create a .htaccess file containing the following code and place this file in Laravel's root directory.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^(.*)$ public/$1 [L]
</IfModule>
More on this:
How can I remove "public/index.php" in the url generated laravel?
Apache rewrite for Laravel /public

.htaccess file 404 error with parallel plesk server

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)

Joomla SEF Apache mod_rewrite not working on new hosting setup, possible RewriteBase rule?

I recently moved my sub-domain hosted Joomla (sub.domain.com) to another host and my SEF URL's are broken. Currently I have Apache mod_rewrite turned off in the Joomla admin forcing the /index.php/ within all URL's
Apache mod_rewrite is loaded and working correctly. The major different in my hosting setup is that before my VPS host had a directory for the sub-domain within the server structure /home/me/sub.domain.com/ now it seems the new host is using another rewrite? as the server files is located in /var/www/domain.com whereas the front-end browser points to http://sub.domain.com
Not sure if there is a custom RewriteBase rule I'm not familiar with to correct this or perhaps there is another rewrite going on within the hosting which I'm not aware of?
Thanks for you time.
Have you made sure, that you DO NOT have set AllowOverride in your vhosts file to "none" ?

Helicon Redirect to IIS6 Virtual Directory - .htaccess Syntax and location

I'm moving my blog which was in a physical folder (/blog/) on my IIS 6 web server to a virtual directory called the same name (blog) running BlogEngine.net, the virtual directory is running in the same application pool as the parent website.
I want to redirect each .html post to the new BlogEngine.net URL. e.g.
http://www.mywebsite.co.uk/blog/2009/06/old-blog-title.html
to
http://www.mywebsite.co.uk/blog/post/new-blog-title.aspx
I already have Helicon ISAPI Rewrite Version 3.1.0.58 running on my website and currently have redirects working fine. But redirects to the blog virtual directory don't seem to work.
Current .htaccess rule:
#rewriterule ^blog/2009/06/old-blog-title.html$ /blog/post/new-blog-title.aspx [R=301,L]
Question 1: Should I add the .htaccess rules to the blog Virual Directory root or the main website root?
Question 2: What .htaccess syntax should I be using to redirect to the virtual directory?
Thanks in advance for your help.
I didn't get any response, but managed to figure it out myself. Is there a StackOverflow badge for that LOL :-)
I'm answering my own question just incase anyone else has the same problem.
Answer to Question 1
The .htaccess file should be located in the virtual directory root, but you can't edit this in the Helicon Rewrite tab of IIS 6 for the virtual directory as it wants to save the .htaccess file in a physical directory called /blog/ rather than the virtual directory.
Answer to Question 2
The rewrite needed to be amended slightly due to the .htaccess file location within the virtual directory. Basically removing blog/ from the beginning of the old url.
rewriterule ^2009/06/old-blog-title.html$ /blog/post/new-blog-title.aspx [R=301,L]
Your rule is OK if you need to redirect just a couple of blog articles, but if you'll have hundreds of them, you'd better have a look at mapfiles functionality of ISAPI_Rewrite here.
but you can't edit this in the Helicon Rewrite tab of IIS 6 for the virtual directory
This problem was fixed in build 62, so update and enjoy.

Resources