Clean URL support in MAMP - php

I am trying to setup a website on my Mac using MAMP. I put my website content into a folder under
/Applications/MAMP/htdocs/positweb
"positweb" containins index.php which tries this redirect:
header("Location: web/main");
Along index.php I have .htaccess file, which came with the website:
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]
I have also enabled "AllowOverride All" inside
<Directory "/Applications/MAMP/Library/htdocs">
element in both httpd.conf and httpd-std.conf files.
Now, my problem is that these redirects don't work on my setup. Chrome says that the link "http://localhost/positweb/web/main" is broken, Firefox says that index.php is not found.
All of the php/.htaccess files are exact copies of a working version of the site. I tried playing around with Apache settings like I described above, but with no luck, and now I don't know what else to try.
My MAMP version is 1.9.5.
Any suggestions are appreciated. Thanks.

Try changing your base_url in the bootstrap.php from / to /positweb

And make sure you've got FollowSymLinks turned on in your httpd.conf.

Related

Installing Drupal 8.2.4 - Clean URLs

So I have attempted to install Drupal 8.2.4 onto a dedicated server that I own.
I am running WampServer 3.0.4 64-bit with PHP 5.6.19 and MySQL 5.7.11.
I successfully get through the installation wizard and to the main page of the website however when I try to go to various pages, none of them work.
This appears to be an issue with Clean URLs. During the installation I get a warning message that Clean URLs is not enabled.
However, I have checked my apache config and rewrite_mod is enabled.
I tried to manually access the admin page # ?q=admin/config/search/clean-urls however it just returns me to the index page.
I've taken a look over the guide here: https://www.drupal.org/node/15365
I tred modifying my httpd.conf by adding the following to the bottom:
RewriteEngine on
RewriteBase /mms-beta
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !=/favicon.ico
RewriteRule ^ index.php [L]
However, then the server won't start.
I've also ensured that for /www/ the AllowOverride is set to All for the purposes of htaccess.
Can someone give me an idea as to what I need to do to get this to work?
UPDATE: So I tried adding garbage to my .htaccess file and it doesn't break, so its clear my htaccess file is not even being read.
Ok, solved.
You need to add an alias under Apache through the wamp tray icon and then modify the conf file.
In the conf file specify as follows:
AllowOverride All
Then delete:
require local
Now htaccess will work correctly.

.htaccess doesn't work on xampp (windows 7)

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().
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
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.
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
Check in httpd.conf you tag, review this property
AllowOverride All
AllowOverride authorize use htaccess file.

Trying to figure out htaccess issues

I'm having some issues figuring out how to use an htaccess file. I've got apache/php installed on an ubuntu system and mod_rewrite is turned on (php_info() states that it's in the list of loaded modules). The web server works, displays html and php files, so I'm happy with that.
What I'm trying to figure out now is how to use an htaccess file properly. I created a directory, /data, with an index.php file in it. All I want it to do at the moment is just display the $_REQUEST variable so I can see if things are working the way I assume they should.
Example: If I type in the following URL: localhost/data/info1/ I want the htaccess file to access localhost/data/index.php?request=info1
However, no matter what I enter in to the htaccess file, I keep getting 404 errors, and I'd like to understand why.
Here's my htaccess file:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule data/(.*)$ data/index.php?request=$1 [L]
</IfModule>
I've made no changes to the config file, to activate mod_rewrite, I used the ubuntu a2enmod command so ubuntu did it for me. After that, I restarted apache.
What I can't figure out is why this doesn't work. My assumption is that there's still some sort of configuration I need to do on the server end, but I honestly don't know what. Is there any advice anyone can offer me?
Here's the fix:
RewriteRule ^data/(.*)$ data/index.php?request=$1 [L]
(You were missing a ^)
EDIT:
In the OP, you have another leading / in the URL example, in this case it'd be:
RewriteRule ^data/(.*)/$ data/index.php?request=$1 [L]

Apache mod_rewrite redirects links to localhost. How to make .htaccess to work with each site in local machine?

I've installed Xampp as a web server and want to make clean URLs for one of my projects. So I put these simple lines in .htaccess file in the root of this project:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
Also I made links in this project like this:
About Us
I expected to go to localhost/this_project/about/, but it does not work. I go to localhost/about/ and this is wrong. How can I solve this problem?
I also have put this line in the 2nd line of .htaccess file, but no change happened.
RewriteBase /this_project/
Attention: There are many directories in htdocs folder for each project.
You htaccess looks OK so I guess you are missing
AllowOverride All
In the VHOST <directory> block. If you server will fail after you add AllowOverride make sure you enabled mod_rewrite.

htaccess file works on server, doesn't work locally

I've been searching around and trying all sorts of different approaches, but I can't seem to figure out what's wrong.
I have the following piece of .htaccess code:
Options +FollowSymLinks
IndexIgnore */*
# Turn on the RewriteEngine
RewriteEngine On
#  Rules
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.php [L]
It works fine on the production server, so that insinuates that the config file is set up okay there.
I'm trying to develop for this site locally though, and there I get 404 errors saying that the file does not exist when I go to localhost/example/login (which corresponds with domain.com/login).
I have tried different settings, setting AllowOverride All, checking if mod_rewrite is enabled in phpinfo(); and what not. But I can't seem to figure out what's wrong.
Any suggestions?
check out if mod_rewrite is enabled. Don`t forget to restart apache.
Check your virtualhosts, is allow override is on?

Categories