Have been around the houses with this - have read many htaccess issues etc - and still can't seem to get this to work.
I have a WordPress site installed at var/www
I wanted to have a specific URL point to a specific page. Started by browsing some WordPress plugins. None of them worked so I just went straight to the source and started editing the .htaccess file in the root of the WordPress installation. This is where it started getting frustrating.
One of the many attempts at an .htaccess file:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
Options +FollowSymLinks
Redirect 301 /redirect-me http://my-wordpress-site/?page_id=15
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
All attempts at a Redirect have resulted in 404 Not Found errors.
I have asserted the following things:
Apache2 Rewrite Module is enabled
www-data has both read and write access to the .htaccess file.
AllowOverride is set to All in the apache2.conf file for the directory
Here's a big clue for you: swapping the last ReWrite rule within my .htaccess file does absolutely nothing to my WordPress site...
RewriteRule . /poo.php [L]
Any other suggestions for debugging a failing .htaccess file?
When you make configuration changes such as AllowOverride in the config, make sure your do a restart on Apache2 so the changes become effective. Give that a shot.
Related
Actually I am deploying my laravel 5 Application on Linode Server.
My client create space for me in such type of path.
var/www/html/abcproject
I point out my godaddy domain to abcproject directory.
Now I have uploaded my all Laravel 5 files on abcproject directory.
My issue is that , my home page is working fine but my internal pages
are giving Not Fount Error.
Suppose when I try to logged in it is giving below error.
Not Found
The requested URL /abcproject/login was not found on this server.
Secondly Laravel 5 URL is getting url like that.
Supposed URL.
http://15.30.19.61/abcproject/index.php/registers
I did not understand where is and what is the issue.
One thing is my project is working fine when I try such type of URL.
http://example.com/index.php/ But In this case my URL Rewriting did not work but project is working like I can logged in, go in different pages, Logout etc.
My HTACCESS FILE
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>
RewriteEngine On
# Redirect Trailing Slashes If Not A Folder...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/$ /$1 [L,R=301]
# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
# Handle Authorization Header
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
</IfModule>
Thanks
If you are powering your laravel project from a sub folder such as you mentioned above:
http://15.30.19.61/abcproject
You should add this to your .htaccess file under RewriteEngine On.
RewriteBase /abcproject
I also faced a similar issue with LAMP configuration and I resolved by enabling rewrite rules of apache. If some needs details then it can be referred at the below blog notes
http://ankgne.com/post/setting-up-digital-ocean-for-laravel-application
Step 1: Enabling mod re-write using sudo a2enmod rewrite
Step 2: Allowing the laravel .htaccess (in public directory of laravel page)
file to apply rewrite rules
sudo vi /etc/apache2/sites-available/000-default.conf and adding below lines
Note: Change "/var/www/html" to "path of laravel public folder"
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Require all granted
. . .
Step 3: Restarting web server using sudo systemctl restart apache2
My wordpress site lies in a folder called /entwurf/cob1 and since I wanted it to be shown by simply typing in www.cob1.org I changed the permalink to cob1.org and now nothing works. I tried changing the htacces to:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /entwurf/cob1/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /entwurf/cob1/index.php [L]
</IfModule>
but this doesnt seem to work either. I want my files who lie in the entwurf/cob1/ folder to be shown when typing in the cob1.org website.
Currently nothing is seen.
Delete .htaccess, log into your wordpress, and let wordpress to generate .htaccess for you. ( Options -> Permanent Links -> Save)
Check is it working? No?
Upload to your web site root phpinfo file (php file with a content of "<?php phpinfo() ?>"), run it via browser.
Check what Server API cell says -> Apache? If yes Check is there mod_rewrite enabled? No? Ask Support to enable it.
If its not a Apache, ask for a help of the person who setup your server.
If you have access to the Worpdress admin panel go to
Setting > General
and make sure the Wordpress URL and Site URL are correct. They should be your new address. Change those and save it if you want to rewrite all the old URLS in the database.
If you don't have access to the WP admin panel try using this to manually make the changes to your database.
https://interconnectit.com/products/search-and-replace-for-wordpress-databases/
Delete .htaccess and regenerate it. Else use the following:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /entwurf/cob1/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.php [L]
</IfModule>
Secondly, what you are trying to achieve has to be done in two steps.
1) In Settings > General, change the wordpress url in both fields to www.cob1.org
2) In your apache config, set www.cob1.org to point to /entwurf/cob1/
<VirtualHost *:80>
DocumentRoot "complete-absolute-path-to/entwurf/cob1/"
ServerName cob1.org
ServerAlias www.cob1.org
</VirtualHost>
3) Verify that .htaccess is being read. This takes a little bit of experimentation. Eg. I'd place some random text in .htaccess to force a server error on purpose. If I see the error, that means that the .htaccess file is being read. If it's not being read, make sure "AllowOverride All" is set in the apache config. .htaccess files are only read by apache (and apache family servers.)
Restart apache. You're done.
I recently installed wordpress , I am facing issues when I try to change the permalinks format ,
when I change the permalink from default to day and time
Default http://127.0.0.1/?p=123
Day and name http://127.0.0.1/2015/03/16/sample-post/
the link generated does't working , it gives the same error 404 all the
time ,
The requested URL /2015/03/16/post-5-problem/ was not found on this server.
But when the permalink type was default this works perfectly.
I found some solutions which are
sudo a2enmod rewrite
Module rewrite already enabled
Another solution is to change the mode permissions of .htaccess file to 666(giving write permission to wordpress of .htaccess file) before change the permalink from default to some other type ,
sudo chmod 666 /address_of_.htaccess
i checked the .htaccess file
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
but the above seems to be correct , the above included by the wordpress itself
Both the solutions does't seem to work , is there any other thing do I have to change to enable the permalink options ?
If it is a fresh install of web server it is possible that .htaccess rules are not allowed by default. To fix that, edit you httpd.conf (usually it is in /etc/apache2), find
<Directory "path/to/your/document/root">
# ....
AllowOverride None
# ....
</Directory>
and change
AllowOverride None
to
AllowOverride All
Then restart your web server and try again.
Reset your desired permalink from wordpress admin area and add this code in htaccess:
# BEGIN WordPress
<IfModule mod_rewrite.c>
ErrorDocument 404 /index.php?error=404
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
Now, check with blog posts and pages.
Thanks,
You can go to preferences -> services & ports and you need to check enabled ssl for Apache
It's working for me
You are receiving this error because your webserver cannot find the file, and it's not passing the request to Wordpress.
You need to add rewrite rules for your Wordpress, and instructions for that depend on your webserver software (Apache, nginx, etc).
Example with nginx:
location / {
try_files $uri $uri/ /index.php?$args;
}
Which literally means: try to open "/2015/03/16/post-5-problem/" in filesystem first, if it doesn't exist try to add a slash, if that doesn't help pass the request to index.php (which is Wordpress main file) with the arguments.
Enabling rewrite module is not enough, you have to add rewrite rule(s).
I just copied a concrete5 project over to my local box and am trying to get it running on localhost. I had permissions problems at the start so I just ran a sudo chmod 777 -R site which remedied that. I then had problems with clicking a link. Anything besides index.php would result in a 404. So I messed around with the htaccess file. It came in this state:
# Use PHP53 as default
AddHandler application/x-httpd-php53 .php
<IfModule mod_suphp.c>
suPHP_ConfigPath /opt/php53/lib
</IfModule>
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME}/index.html !-f
RewriteCond %{REQUEST_FILENAME}/index.php !-f
RewriteRule . index.php [L]
</IfModule>
and I changed it to this:
# Use PHP53 as default
AddHandler application/x-httpd-php53 .php
<IfModule mod_suphp.c>
suPHP_ConfigPath /opt/php53/lib
</IfModule>
<Directory>
AllowOverride All
</Directory>
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>
RewriteEngine On
RewriteBase /
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME}/index.php !-f
RewriteRule . index.php [L]
</IfModule>
Now, none of that helped. I decided to just disable pretty URLs in the database. I did that and most links work. It looks like some still don't (maybe the ones that are involved in a package. I don't know because I am picking up this project where someone left it). Bear in mind this all works perfectly on the live server at this time with the first .htaccess file I showed.
Any idea as to how to remedy this?
It does sound like you are having an issue with Pretty URLs. The ones that are still not working after you disabled it are likely do cached items like blocks. If you clear you cache your site will likely work without Pretty URLs turned on.
As for why Pretty URLs are not working, I would first make sure that mod_rewrite is enabled. Then you can try a couple of these for the rewrite rule.
RewriteRule ^(.*)$ index.php [L]
RewriteRule .* index.php [L]
Note: you can use the scripts from your admin login to update "pretty URLs". One caution would be is that if you use .htaccess for another purpose on your site.
Try removing the htaccess completely. Rather than deleting it, rename it. Then get into the dashboard directly at /index/dashboard/ , disable pretty urls, disable and clear the cache, and clear your browser cache.
(In general, always disable pretty urls and disable and clear the cache before cloning a site.)
Once everything is working without pretty urls, you can then start re-enabling.
I've just hit this one whilst trying out concrete5 on my home machine (linux/apache).
In my case, the problem appears to have been because I'd installed concrete5 two directory levels beneath the document root (/var/www/html). Initially, I just created the .htaccess file based on the values given when I enabled pretty urls, then hit the "page not found" problem (couldn't even log in.) Eventually, the penny dropped: I edited .htaccess and changed RewriteRule to point to the actual location of the concrete5 index.php relative to /var/www/html.
So in my case, concrete5 is installed into /var/www/html/playpen/public_html - so the new RewriteRule reads:
RewriteRule . playpen/public_html/index.php
and that appears to work.
Hope it helps someone ...
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.