How do I configure pretty urls on my WordPress blog? - php

I am new to Wordpress (and PHP). I am trying to make WP MVC's sample run on my wordpress:
http://wordpress.org/extend/plugins/wp-mvc/
I added the plugin and can see data listed in my events menu but when I click View, it tries to browse:
http://localhost/mysite/events/1
and it can't I get 404 error and I suspect it is most probably due the fact that Wordpress is not configured for pretty urls.
So I went in my admin site and under Settings/Permalinks I selected 2nd option of Day and name and I still get 404 error. Also on my home pages my posts disappeared and I get:
Apologies, but the page you requested could not be found. Perhaps searching will help.
Has anybody had any experience with WP MVC?
PHP is making my head hurt:(

I am not a PHP guy but can try going into your httpd.conf and see if your rewrite module is commented or not. If there is any # in front of it remove it and then restart wamp and try. I think this is mostly due to the fact that your module is not enabled. Let me know if it helped you.
Specifically this line:
LoadModule rewrite_module modules/mod_rewrite.so
Make sure there is no # in front of it.

When you set a permalink structure in Settings > Permalinks, WordPress attempts to write an .htaccess file to the root of your site, probably similar to this default:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
My file permissions are locked down a bit tighter than that, so I see the suggested contents at the bottom of the Permalink page, with some brief instructions. Are you seeing something similar? Did WordPress create an .htaccess file? Do you have mod_rewrite installed? (I don't recall if WordPress can autodetect mod_rewrite.)

Related

Wordpress in subfolder insists on showing the parent directory's contents

I'm attempting to migrate our wordpress blog from blog.ourdomain.co.uk to ourdomain.co.uk/journal, but ourdomain.co.uk/journal always shows the content from ourdomain.co.uk/.
To keep the migration simple, I started with a blank wordpress install in /journal, then imported 'All Content' using WP's built in export/import features.
All seemed well at first, but when I visit ourdomain.co.uk/journal it does not show a wordpress home page, but instead the home page of our main site. Even visiting ourdomain.co.uk/journal/index.php results in this behaviour. This site issues a 301 to redirect to ourdomain.co.uk/journal, and then I see the main site homepage rather than wordpress.
I can't see anything in the parent directory .htaccess file which would make this happen. The wordpress .htaccess file contains the code as per below, most of which was auto-created by wordpress, but I added the wp-admin redirect rule.
I can visit and use https://www.ourdomain.co.uk/journal/wp-admin/ no problem. Database cxn is OK. I can also visit static files such as https://www.ourdomain.co.uk/journal/readme.html. Links direct to posts also work fine, such as https://www.ourdomain.co.uk/journal/2021/post-title-here/ - it's just the homepage.
Even if I set the home page to be a static page, such as our about page in wordpress, this still happens.
I have defined define('WP_HOME', 'https://www.ourdomain.co.uk/journal'); and define('WP_SITEURL', 'https://www.ourdomain.co.uk/journal'); in wp-config.php
If I delete the contents of the /journal .htaccess file, then I am able to load https://www.ourdomain.co.uk/journal ONCE, then it goes wrong again because wordpress has rewritten the rewrite code to .htaccess - so clearly this is something to do with permalinks, but I'm unable to figure out what, exactly, the deal is.
Any help gratefully received.
Contents of .htaccess:
# BEGIN WordPress
# The directives (lines) between "BEGIN WordPress" and "END WordPress" are
# dynamically generated, and should only be modified via WordPress filters.
# Any changes to the directives between these markers will be overwritten.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteBase /journal/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /journal/index.php [L]
</IfModule>
# END WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^wp-admin\/?$ wp-admin/index.php [NC]
</IfModule>
OK, has worked for 24 hours now so: fixed by adding 'DirectoryIndex index.php' to .htaccess. Looks like redirection was just going up the folder tree until it found a directory index page it recognised, so making it recognise the one in /journal fixed it.

Changed mac username, now WordPress permalinks not working

I changed the user folder name on my macbook, now I get a 404 when accessing a child page via localhost using my local apache2 server.
I can't 100% guarantee this is what is causing my woes, but that is a major recent change - and since then I can't load interior pages/posts.
eg: http://example.dev/childpage
Homepage loads, WordPress Admin works - just subpages.
Trouble-shooting so far:
Saved Permalinks in the WordPress Admin to regenerate them
Updated /etc/apache2/extra/httpd-vhost.conf
Grepped /etc/apache2/ to verified no old username
Restarted Apache (restarted my computer!)
Grepped /Users/newuser recursively for old username
Followed this post using functions.php and wp-config.php methods and regeneration steps
Verified via phpinfo(); and /etc/apache2/httpd.conf that mod_rewrite is enabled
.htaccess contains typical single site entry
Would be happy to hear from someone who's found the secret key.
Thanks!
Having done all the above steps, and still seeing no success with the typical .htaccess in the docs, I found that adding /index.php/ to the custom slug revives things. This concludes that all hope is not lost and that I just need to take a deeper look at the .htaccess rewrite rules to omit the unsightly index.php.
EDIT:
Answer via:
https://coolestguidesontheplanet.com/403-forbidden-error-wordpress-htaccess/
Add “Options +FollowSymLinks” to your .htaccess file at start of the file:
Options +FollowSymLinks
# 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
Thanks everyone!

Wordpress site on AWS throws 404 error on all but homepage

I have a site that is live on AWS - Wordpress, latest version, custom theme
It works fine in MAMP on my laptop, but on the live site, none of the pages besides the homepage work with the permalinks as /%post-name%/
I can make the permalinks work if I change them to default.
I don't think it has to do with htaccess, I've tried scrubbing it, we made some edits to it, and that has not made a difference.
Here are the contents of htaccess:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /ucampaign/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /ucampaign/index.php [L]
</IfModule>
I think it has to do with settings in the AWS instance, which I know can get complicated. But I wouldn't know where to look.
Thank you for looking at this, if there's more information needed to figure this out, I will be happy to provide :-)
Looks like a missing mod_rewrite. check apache config for that. Also, make sure Apache is reading the .htaccess file. When I say check to make sure the .htaccess is being read, does the server throw an error when you place junk inside the .htaccess file? What type of OS are you running on AWS?

wordpress wpml plugin - problem in language switching

I'm using the wamp package(Apache server) in my windows xp. After i followed the steps in the url click here i'm not able to access the different language. The problem i'm facing in the .htaccess file. under the www folder i put all my wordpress files in the name wsa26-4. So the file structure will come like this wamp/www/wsa26-4/wordpress files. So i used the following code in my htaccess file.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /wsa26-4/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
But the problem i was facing is when i click the language switcher flag say german then it's redirecting to me the default wamp server page.(http://localhost/wsa26-4/de-->localhost index page).. How i can fix this issue??
It's difficult to debug the .htaccess file like this.
What I always do is go to WordPress->Settings->Permalinks and save from there. Then, either WP can update the .htaccss file itself or it gives me the text to paste in.
In order for WPML to use languages in directories, 'fancy permalinks' need to work. You should test it first without WPML. Set a permalink structure such as 'Month / Day / Postname' and see that it works. For this, the server's rewrite module should work.
The .htaccess file needs to have the rewrite engine enabled (see the IfModule declaration). You should check if your local Apache server has this module enabled and if not, enable it.
Then, when this is OK, you can safely enable WPML's language directories option and it should run without any issues.

Wordpress throws 404 when I try to use a custom template page

I made a custom page template (for example, for About page), added Template Name inside the file and saved that. Then I tried to add a page in wp admin console using that template. It said that the page had been created successfully but when I try to open it in browser, it shows me 404 error. What did I do wrong?
Thanks.
I forgot to say that I set up permalinks to be /%postname%/ and then it give me that error. If I use no permalinks (default setting), it show the page normally.
Friends,
I made a single change to the custom template and it fixed the above issue.
Instead of
require_once('./wp-blog-header.php'); in the custom page for including Wordpress theme,
I used this,
require_once('./wp-load.php');
That fixed me the problem.
Please let me know if its working for you. I spent hours tracking and fixing this up for theworksheets.com
I think the problem is nothing to do with your custom template, but your permalink structure.
It's not really recommended to just use /%postname%/ - quoting from the Codex;
Starting Permalinks with %postname% is strongly not recommended for performance reasons..
What's the slug (the 'sanitized' title used in the URL) of the problem page?
Make sure you've rebooted Apache after editing the config file.
Also check there is a .htaccess file (no filename, with an extension 'htaccess') in your WordPress root, and that it contains;
# 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

Categories