Joomla | enabling SEF removes index.php, but returns a 404 page. Page visible thru index.php/page. How to fix? - joomla-sef-urls

I'm running Joomla 2.5.8 and I'm trying to delete the stupid index.php so having SEO friendly URLs. Yet.. When enabled and rebuild' the menu, when I click on a menu item the site goes to the page without the /index.php/ BUT it returns a 404 page. However, when I manually type /index.php/ between the domain and the page, I see the normal page.
A few notes
I changed htaccess.txt to .htaccess
I removed the '#' before RewriteBase /
I added 'cms' to the directory path (RewriteBase /cms ) Since Joomla is in the /cms folder
However, the htaccess is in the SAME folder as Joomla itself, they both lie in a subfolder
In the root folder, where a different website is stored, there also lies a .htaccess file
Any suggestions guys?
Thanks!

Sounds like your config is OK.
The htaccess with RewriteBase /CMS, should be in the /CMS folder.
In Joomla you should have sef rules enabled and use mod_rewrite option enabled.
This could simply be a cache clearing issue.

Related

Redirect a forbidden URL in Apache

I would like to move an entire directory and its subdirectories from one Apache server A to another Apache server B, and then create a redirection from A to B.
i.e.
http://server_a.com/docroot/dir to http://server_b.com/docroot/dir.
This is what I did:
I copied the files and directory structure under dir from A to B
I deleted the directory dir on A
I created a rule in docroot/.htaccess on server A that reads
Redirect permanent dir/ http://server_b.com/docroot/dir/
But when I go to http://server_a.com/docroot/dir/path/to/file/index.html, I get a 403 Forbidden, even if the target page http://server_b.com/docroot/dir/path/to/file/index.html is up.
I know that the .htaccess is read by Apache, because it correctly controls other parts of server_a. I am not root on these servers. I have also tried with a RewriteRule, with the exact same results.
How should I go about creating a redirect in this case? Thanks.
If you have mod_rewrite enabled than you can do this
RewriteEngine On
RewriteRule ^/?docroot/dir(/.*)?$ http://server_b.com/docroot/dir$1 [R=301,L]
Put it in your .htaccess file in the Document Root directory http://server_a.com/.
Note:
Delete you Browser cache first.
You'll need the leading / in the old URL. Like this:
Redirect permanent "/dir" "http://server_b.com/docroot/dir/"
See the mod_alias docs for more details.

https before address shows only files in private_html folder on host

when i try my webpage address with https, page shows only files in the private_html folder not public_html.
but my website runs in the public_html. for example i use an index.html file (including forwarder script) and when you type https://alirezah.net it redirects to http://alirezah.net.
how can i fix it? I wanna use cloudflare ssl service but this happens.
I tried to edit htaccess but it doesn't help
If your website is hosted on Directadmin, then follow these steps:
Log in to your DirectAdmin control panel
Click on Domain Setup
Click on the domain name you wish to change this for
Choose the Use a symbolic link from private_html to public_html - allows for same data in http and https checkbox.
Note the warning message - anything in private_html will be removed, so be sure you do not have content left here that you want to keep.
Accept the warning notice and your now pointing you are private_html directory to the public_html directory.
If your website is installed in private_html it will be deleted using this function. If you want to keep your website installed in private html and also redirect http to https, then you need to create a .htaccess file in public_html with the following contents:
RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteRule .* https://example.com/%{REQUEST_URI} [R,L]

Apache cross domain 404

I want to make apache to always open up a signle page for 404 errors from all subdomains.
The problem is that my subdomains are located in subfolders in public_html, and thus have a different root path.
For example the main domain this works quite well:
ErrorDocument 404 /Error/404.html
The Error folder and the main domain are located in public_html respectively.
However for the forum subdomain, located in public_html/forum/ the above root path does not, and it actually looks for public_html/forum/Error/404.html which doesn't exist.
I tried to rewrite rule for the forum folder, but it didn't work out either:
ErrorDocument 404 /../Error/404.html
Seems, it cannot go below the root folder for some reason.
Any ideas how can I refer to the same page from the main and the subdomain alike, without triggering redirects? (eg: http://mysite/Error/404.html would accomplish this, but would also change the url address of the page which I don't want)
Seems, it cannot go below the root folder for some reason.
Because being able to traverse above the document root is a very, very serious security risk. If your webserver gets compromised, people would be able to serve all kinds of files anywhere on your entire server.
If you have access to server config you can setup aliases for the /Error folder. For example, in your forum subdomain's vhost config, you can add:
Alias /Error /path/to/public_html/Error/
This way, when you go to http://forum.yourdomain.com/Error/404.html you'd actually be looking at http://main.yourdomain.com/Error/404.html. Then you can just use:
ErrorDocument 404 /Error/404.html
like normal in your forum subdomain.
But if you don't have access to your server/vhost config, you'll need to use mod_proxy and mod_rewrite. So in the htaccess file in public_html/forum/, add these to the top:
RewriteEngine On
RewriteRule ^Error/(.*)$ http://main.yourdomain.com/Error/$1 [L,P]

How do I force Apache to simply redirect the user and ignore the directory structure?

Ok, so this problem recently arose and I don't know why it is happening; it's actually two problems in one...
0. My .htaccess file, for reference. (EDITED)
Options -Indexes +FollowSymLinks
RewriteEngine On
RewriteBase /
ErrorDocument 400 /index.php?400
ErrorDocument 401 /index.php?401
ErrorDocument 403 /index.php?403
ErrorDocument 404 /index.php?404
ErrorDocument 410 /index.php?410
ErrorDocument 414 /index.php?414
ErrorDocument 500 /global/500.php
RewriteCond %{HTTP_HOST} !^$ [NC]
RewriteRule .* index.php [L]
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^https?://(.*\.)?(animuson)\.(biz|com|info|me|net|org|us|ws)/.*$ [NC]
RewriteRule ^.*$ - [F]
1. My 'pictures' folder is following the hard path instead of the redirect.
I have no idea WHY it is doing this. It's really bugging me. The 'pictures' folder is a symbolic link to another place so that I can easily upload files to that folder without having to search through folders and such via my FTP account, but that's the only thing I use it for. However, when I visit http://example.com/pictures my htaccess sees it as accessing that other folder, which is restricted, and throws a 403 error rather than redirecting to index.php and displaying the page like normal.
I figured it has something to do with that specific folder being a symbolic link causing it to act oddly, but I have determined that my rules are not being applied to folders at all. If I visit folders such as 'css' and 'com' which are folders in the web root, it displays a 404 error page and adds the '/' to the end of the URL because it's treating it as a directory. It also does the same 403 error for my 'images' directory which is set up in the same fashion.
So, the question here is how do I modify my RewriteRule to apply to the directories as well? I want everything accessed via the web to be redirected back to index.php while maintaining the full access path in the address bar, why is it not working? (I'm pretty sure it was working fine before.)
Here's a small chart to show the paths they're following...
example.com/pictures -> pictures/ -> /home/animuson/animuson-pictures -> 403
example.com/com -> com/ -> 404
example.com/test -> index.php
example.com/ -> index.php
example.com/images -> images/ -> /home/animuson/animuson-images -> 403
example.com/css -> css/ -> 404
EDIT: Following information added.
Apache is processing the structure of the directory first. It's determining if the path exists based on what was typed into the address bar. If someone types in a folder name that happens to exist, it will redirect the user to the path with the "/" at the end of the URL signifying that it's a directory. For the 'pictures' directory explained above, the user does not have permission to access that folder so it is redirecting them to a 403 Access Denied page rather than simply showing the page that is supposed to be displayed there via the RewriteRule above. My biggest question is why is Apache processing the directory first and how do I make it stop doing that? I would really love an answer to this question.
2. Why is my compression not working? (EDIT: This part is fixed.)
When analyzing my site through a web optimizer, it keeps saying my page isn't using web compression, but I'm almost 100% positive that it was working fine before under the same settings. Can anyone suggest any reasons why it might not be working with this set up or suggest a better way of doing it?
Where is this .htaccess file situated? At the root or in the pictures directory?
1) You're using Options -Indexes which will deny access to directory listings. This is handled by /index.php?403 which in turn will redirect to /403. (I confirmed this by manually going to /index.php?403) I don't see any other rules in the posted .htaccess that are supposed to affect this. So this either happens because either index.php or some other .htaccess file or server rule makes that redirect.
You might also want to check the UNIX file permissions of the directory in question.
2) According to this aptimizer, http://www.websiteoptimization.com/services/analyze/, compression is indeed enabled for html, js and css files, as specified in the rules. My bet is that the optimizer is being stupid and does one of these three things:
1)) Complaining about images not being compressed. (It's generally a bad idea to compress images because they're typically already compressed and the extra CPU load typically isn't worth it since the net gain is so small. So your rules are OK in this regard.)
2)) It might think that DEFLATE doesn't count as compression, and wants you to use GZip.
3)) It might also react to the externally included StatCounter js file, which is not compressed. (And there's not much you can do about that.)
After a while of deliberating on Apache's IRC channel, I was finally able to figure out the real reasoning behind this on a fluke. I just happened to be looking at the directory structure using ls -l and noticed that all of the symbolic links had somehow has their permissions changed to animuson:animuson from the root:root original. I tried to run a simple chown root:root on them and it had no effect, so I deleted them all and recreated them and the problem has gone away. I don't really have any idea why the permissions made any different in this scenario but the solution worked and everything is okay now. I've also added a DirectorySlash Off to my .htaccess file to get rid of the slashes after folders that exist, just to make it look all that much nicer.

Apache mod_rewrite help with Wordpress

I administer my wife's site, namelymarly.com. Up until last week, the root page of the blog was namelymarly.com/blog/.
Last week I changed it in the WP settings to be namelymarly.com.
WP created the new htaccess file, and I moved the index.php to the root directory (but left the WP folder where it was in the /blog/ directory), as instructed. Everything is working great except for one very important thing:
When you type 'namelymarly.com/blog/' into a browser now, you get a 404 error.
All other URLs, when they include the '/blog/somethinghere', will redirect properly to '/somethinghere.' It's only when there's nothing after '/blog/' that there's a problem.
I tried adding this rule but it still redirects to the 404 page:
RewriteRule ^/blog/$ /index.php
Any suggestions/help?
install "Redirection" and then add a 301 redirect from namelymarly.com/blog/ to namelymarly.com
Did you follow these diections?: Moving WordPress « WordPress Codex
You don't need the redirection plugin. Wordpress handles redirects if you regenerate permaliks. If you have to, use this in .htaccess before the Wordpress rewrite block:
Redirect 301 /blog http://namelymarly.com
But first, be sure you've reset your permalinks in Dashboard/Settings/Permalinks and make sure that copy the changes to .htaccess yourself and that there is only the most recent - the last - rewrite block in the file (WP has a habit of adding more and more rewrite blocks to .htaccess).
And check the URLs of your other URLs in the post/page editor and see if they contain /blog/