Installing Drupal 8.2.4 - Clean URLs - php

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.

Related

Apache rewrite not working on custom extension

I'm working on a PHP web app which will route every incoming request to the index.php same as WordPress or Joomla.
Following .htaccess is used to implement the feature.
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
It is working on Wamp server [Windows] and IIS but when I migrate the app to the Ubuntu 16.04.02 [Apache 2.4.18, php7.0.18, Google Cloud Engine], it stops working for some custom extension file. It still working on normal php files thought.
I created a folder called service to put the web service php files and named the files as ****.svc.php and used with ****.svc url. It was working fine before but it is not on the Ubuntu and shown the following error.
Not Found
The requested URL /service/retrieve_opened_rs.svc was not found on this server.
Apache/2.4.18 (Ubuntu) Server at ******* Port 80
I believe this is the configuration issue but I still cannot figure out how to fix after 3 days. Please help me. Thanks in advance.
You probably have the Multiviews option enabled. This never behaves well along with rewrite rules, especially with "double" extensions like .svc.php
Add this at the top of your .htaccess file and that should take care of it:
Options -Multiviews
You might have to tweak your AllowOverride directive (from the main Apache conf) if you don't have the rights to modify Options from an .htaccess file.

.htaccess rewrite on $page

It seems I am stuck. I have found answers, but I can't get them to work.
I am working on this website. I use a switch to determine what content should be visible. I use the variable $page.
The links with this method are not good for SEO so I want them to be /example instead of index.php?page=example.
I have looked at all the different answers to this on StackOverflow, but I can't get any solutions to work. There are no errors coming up and the site will show just fine, but the rewrite doesn't work.
I have tried on both my servers on servage.net and one.com
Any suggestions? :D would be much appreciated!
Try adding this to the .htaccess file in your web document root folder (often public_html or htdocs), then point your browser to example.com/somepage:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^./]+)/?$ page=$1 [L,R]
Once you are satisfied that the redirect works, you can change the R to R=301 to make it permanent.
This assumes that mod_rewrite is both installed and activated for htaccess files.
If you are not sure, to check if mod_rewrite is installed, look at the list of installed modules in the output of phpinfo();
By default, mod_rewrite is not enabled for htaccess files. If you are managing your own server, open httpd.conf
and make sure that the webroot directory block contains one of these lines: AllowOverride FileInfo or AllowOverride All

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]

Zend Framework Giving 404 Error For Controllers

I am using Zend Framework on Ubuntu 11.10 (my local dev machine). When I navigate to my application with this URL, the front page/index controller works fine:
http://localhost/myapp/public
So I know that for the most part everything is working. The problem comes when I try to access another controller with something like:
http://localhost/myapp/public/faq
This returns the 404 error "The requested URL /myapp/public/faq was not found on this server."
I used the Zend_Tool to create the controller like "zf create controller faq" which gave me FaqController.php with a default indexAction(). It also created the faq.phtml view. This all works just fine on my laptop (Windows XP) so I know it has to be something with configuration.
Here is my .htaccess (it's the default one):
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ index.php [NC,L]
In an attempt to get it to work, I added this into my httpd.conf file and restarted apache:
<Directory />
Options FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
</Directory>
When that didn't work I tried putting that directly into my .htaccess file, but that was a no-go as well. What am I missing? What is stopping Zend from being able to rewrite and route requests?
[SOLVED]
Thanks for viewing, I ended up finding the solution. With Ubuntu, in the /etc/apache2/sites-enabled/ directory is a file called 000-default which contains configuration options.
I was unaware it was there, it had all the AllowOverride options set to None so I changed them to All, restarted Apache, and voila!
To ensure anybody who finds this question via search has full help, I'd like to pass on to make sure mod_rewrite is enabled (mine was) by opening a terminal and running:
sudo a2enmod rewrite
That is how you enable an Apache mod in Ubuntu.

Clean URL support in MAMP

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.

Categories