404 error after changing permalinks wordpress - php

My site is a Wordpress-site created with PHP.
I have made changes in permalink default to postname. It works fine in Chrome and Firefox but not in IE8. The front page displays correctly but when I click a link to another page, it shows a 404 page not found error.
I'm using Wordpress version 3+.
.htaccess file is
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /wordpress/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /wordpress/index.php [L]
</IfModule>
# END WordPress
where WordPress is folder name.
also in apache rewrite_module is enable

First put a .htaccess file in your /var/www/ folder and make it writable.
Second, suppose your wordpress blog is in /var/www/blog folder then go to /etc/apache2/sites-available/
and make following changes in default file
<Directory /var/www/>
Options +ExecCGI
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
<Directory /var/www/blog/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
Now restart apache to make sure changes have taken effect. Hope it helps.

After trying all of these answers and the instructions on codex.wordpress.org, I needed to enable mod_rewrite on Apache:
https://stackoverflow.com/a/5758551/728287

Just go into wordpress /wp-admin, which will still work, and navigate to settings->permalinks. When you go to that page, wordpress will rebuild your .htaccess file and everything will work again.
EDIT (FROM http://codex.wordpress.org/Using_Permalinks)
If the above does not work:
Paged Navigation Doesn't Work
Sometimes navigation to second (and subsequent) pages of posts does not work as expected.
The result of clicking one of those links is that the page loads with all the surroundings (header, footer, sidebar), but instead of a page of posts, there is an error message: "Sorry, no posts match that criteria."
This is due to a glitch in the .htaccess file that WordPress generates.
To fix it, delete the contents of your .htaccess file and re-create it.
In the Control Panel, go to Manage > Files (More Info on Editing Files)
Click the link to your .htaccess file to edit its contents
Copy the contents of the file and paste it to a text file in a text editor. This is a precaution in case your .htaccess file has manual entries for redirects, denials or other handy htaccess tricks
Delete all contents from your .htaccess file and click the Update File button.
In the Control Panel, go to Options > Permalinks.
Click the Update Permalink Structure button to freshly generate new rewrite rules for your permalinks.
Test the results using a link that had previously broken.
Add any manual htaccess entries back in your file (Place manual htaccess entries before the # BEGIN WordPress or after # END WordPress lines.)
You may also perform similar steps by deleting the .htaccess files from the server, creating a fresh empty .htaccess file, changing its permissions to 666, and then in Options -> Permalinks generate a new set of htaccess rules by clicking the Update Permalinks Structure button.
If that still doesn't work, take a look at the WordPress support forums, specifically http://wordpress.org/support/topic/permalink-nextpage-doesnt-work#post-283222

I had the same issue locally, I tried everything above. After a while I realised how the vhost is setup for the application the .htaccess is not enabled.
<Directory "/Applications/XAMPP/htdocs/wordpress">
Options FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
</Directory>
Adding these lines, helped me a lot and resolved my issue.

Enable rewrite_module in Apache-> Apache Moduels

Related

Friendly URL in PHP and htaccess

I have a website built in PHP. Currently my URLs look like:
http://www.domain.com/web/views/site/event.php?id=1&name=Test
I want them to be like:
http://www.domain.com/event/id/1/name/Test
How can I achieve this? I have tried multiple tutorials and have checked for answers in stackoverflow but have not been able to find a proper solution.
Any thoughts?
Thanks in advance.
Create an .htaccess file and add the following lines:
RewriteEngine On # Turn on the rewriting engine
RewriteBase /
RewriteRule ^event/id/([A-Za-z0-9-_]+)/name/([A-Za-z0-9-_]+)/?$ web/views/site/event.php?id=$1&name=$2 [NC,L]
Two things that you should keep in mind:
.htaccess should be located at your root directory
Make sure that apache has the following directive regarding your root directory:
AllowOverride All
This is how is done:
If you have root access to your server, edit the httpd.conf file, find the root <Directory> line, and change it to this:
<Directory />
Options FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
</Directory>
If you don't have root access, ask your server administrator to do that for you.

Mod re write breaking url

Update I have re- done the code and folder system of my mod re write on localhost still nothing
the link only shows like this
http://localhost/cms/member/profile.php?member=10308
my entire .htaccess file
RewriteEngine On
RewriteRule ^cms/member/([^/]*)$ /cms/member/profile.php?member=$1 [L]
when i click on the link it does nothing. if i change in the browser to
http://localhost/cms/member/10308
it says page cannot be found.
Update the problem was this peice of code causing it to not display right
<?php
if(empty($_GET['member']) || $_GET['member'] <1000 ) {
redirect(ROOT_URI);
exit;
}
?>
But i need this code.
the url will work but i need to type it in manually it wont automatically change the url
As you are using an .htaccess file which is placed under the directory "cms", you should use the following directives:
RewriteEngine On
RewriteRule ^member/([^/][0-9]*)$ member/profile.php?member=$1
This will send the request http://localhost/cms/member/(any-number) to http://localhost/cms/member/profile.php?member=(any-number)
Note:
mod_rewrite should be enabled.
In httpd.conf (or apache2.conf), replace AllowOverride None by AllowOverride All to enable .htaccess
Restart Apache server.

SEO friendly URLs for Magento

I am a newbie to Magento and Apache conf. I'm using Magento 1.8.0. I have configured the path so as to remove index.php from the URLs for my pages eg
from
/magento/index.php/electronics/cell-phones.html
to
/magento/electronics/cell-phones.html
However my browser requests now direct to the index.php of my server root. I have tried adding a config section for magento as shown, but no change. What am I doing wrong?
<Directory "C:/hiddenpath/apache2/htdocs/magento">
Options All
AllowOverride All
Order allow,deny
Allow from all
Deny from none
</Directory>
In your .htaccess file find Rewrite Base/ and replace it with Rewrite Base/magento if it is commented using # un comment it.

What is Options +FollowSymLinks?

I am using a Lamp server on my computer. I started to use Laravel php framework.
In my .htaccess , If I use Options +FollowSymLinks , I get 500 error.
And If I comment out , I have to use index.php in my all addresses ..example:
/~ytsejam/blog/public/index.php/login
I use Arch Linux . Is there a way to solve it?
edit: I solved this by using virtual hosts. And deleting index.php from application/config/application.php in laravel folder.
You might try searching the internet for ".htaccess Options not allowed here".
A suggestion I found (using google) is:
Check to make sure that your httpd.conf file has AllowOverride All.
A .htaccess file that works for me on Mint Linux (placed in the Laravel /public folder):
# Apache configuration file
# http://httpd.apache.org/docs/2.2/mod/quickreference.html
# Turning on the rewrite engine is necessary for the following rules and
# features. "+FollowSymLinks" must be enabled for this to work symbolically.
<IfModule mod_rewrite.c>
Options +FollowSymLinks
RewriteEngine On
</IfModule>
# For all files not found in the file system, reroute the request to the
# "index.php" front controller, keeping the query string intact
<IfModule mod_rewrite.c>
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>
Hope this helps you. Otherwise you could ask a question on the Laravel forum (http://forums.laravel.com/), there are some really helpful people hanging around there.
Parameter Options FollowSymLinks enables you to have a symlink in your webroot pointing to some other file/dir. With this disabled, Apache will refuse to follow such symlink. More secure Options SymLinksIfOwnerMatch can be used instead - this will allow you to link only to other files which you do own.
If you use Options directive in .htaccess with parameter which has been forbidden in main Apache config, server will return HTTP 500 error code.
Allowed .htaccess options are defined by directive AllowOverride in the main Apache config file. To allow symlinks, this directive need to be set to All or Options.
Besides allowing use of symlinks, this directive is also needed to enable mod_rewrite in .htaccess context. But for this, also the more secure SymLinksIfOwnerMatch option can be used.
How does the server know that it should pull image.png from the /pictures folder when you visit the website and browse to the /system/files/images folder in your web browser? A so-called symbolic link is the guy that is responsible for this behavior. Somewhere in your system, there is a symlink that tells your server "If a visitor requests /system/files/images/image.png then show him /pictures/image.png."
And what is the role of the FollowSymLinks setting in this?
FollowSymLinks relates to server security. When dealing with web servers, you can't just leave things undefined. You have to tell who has access to what. The FollowSymLinks setting tells your server whether it should or should not follow symlinks. In other words, if FollowSymLinks was disabled in our case, browsing to the /system/files/images/image.png file would return depending on other settings either the 403 (access forbidden) or 404 (not found) error.
http://www.maxi-pedia.com/FollowSymLinks

How can I stop users from viewing folders that have no index page but other pages on my web site using PHP or mod rewrite?

I just wanted to know how to stop user from viewing folders without index pages using PHP or mod rewrite?
All of these answers are good but I will rate the one with the most votes.
Configure your web server to not automatically serve directory indexes.
Using Apache, this is done with the -Indexes option:
<Directory /web/docs/spec>
Options -Indexes
</Directory>
You can also put this Options -Indexes directive in an .htaccess file in the specific directory.
You don't need PHP for this. Just put a blank index.html in the directory.
By viewing folders, I assume there is a directory listing that you don't want visible. In that case, in your .htaccess file:
Options -Indexes
This can be done on a per-directory basis. See:
http://httpd.apache.org/docs/1.3/mod/core.html#directory

Categories