Clean URLS/.htaccess - .htaccess

<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?q=$1 [L,QSA
Looking for feedback
Goal: I am trying to enable "Clean URLs" on a Drupal 7 site (such that example.com/?q=user resolves to example.com/user).
I've just spent way too long pouring through official Drupal docs and comments, to no avail, so any suggestions are greatly appreciated!
I have checked the box "Enable Clean URLs" in Drupal (/admin/config/search/clean-urls) and got the all-clear that the configuration options were saved. So now I am actually able to go to example.com/user and it does indeed display the same content as example.com/?q=user. What I want, however, is for example.com/?q=user to be rewritten in the URI as example.com/user.
The relevant .htaccess code is shown above, and my Apache conf appears to be properly configured.

Clean urls do indeed work but I kept getting errors until I found this
This saved my sanity:
disable Overlay module
go to Clean URLS
change URL from: /?q=admin/config/search/clean-urls
to: /admin/config/search/clean-urls
Then the Check box should appear

I was searching for this issue, the solution that work for me was that:
Left click on the wamp server icon and go to the apache.
Here sub menu will be opened, go to the apache modules and enable the rewrite_module.
now restart wamp server and then check your site.
Enable clean url will now be active.

there should be a closing bracket on your last line "]". Perhaps this is the source of your frustration?

Related

How do i change the .htaccess on cPanel's Online File Manager (ByetHost)?

I'm using ByetHost as my website's FTP service, i configure everything (besides uploading the stuff) via ByetHost's Vista Panel, which has a Online File Manager where i presume i could edit the .htaccess.
However when i arrive at the File Manager, i can't seem to find the .htaccess file, and there is also a lack of a Settings button too.
Here is what the File Manager looks like: (the htdocs is where all my website's stuff is at)
I know ByetHost and/or whatever this unknown File Manager is not well known, but i'd like to ask anyways if there's anyone that could help me on how to configure my .htaccess. I would appreciate it.
I had this issue too, and couldn't find any settings or otherwise.
So what I simply did was:
Just created a new file and named it .htaccess!
And a quick test, I put in the following to allow access to my .html pages without actually typing the extension:
RewriteEngine on
RewriteRule ^(.+)\.html$ /$1 [R,L]
RewriteCond %{REQUEST_FILENAME}.html -f
RewriteRule ^(.*?)/?$ /$1.html [NC,END]
And it worked successfully.

Joomla - htaccess Redirects Error

I've had a Joomla 2.5.28 site for quite a while now and recently changed hosting providers. On the new server I managed to get Joomla updated to 3.2.7 and get it to run normally.
Now for the tricky part:
On my previous hoster I had a second installation being kind of the gateway to the other site. It just lets you select language and that's it.
My domain is www.cyclingtoserve.at with Joomla Main being /joomla and Joomla portal being /3.1
I figured by adding a REDIRECT rule from / to /3.1 I could get the portal up and running again. Sadly not.
This is what I get:
I thought I could undo this by deleting the .htaccess file. The problem lives on though.
I've tried just about everything. Help is VERY MUCH appreciated!
Edit01: A bit more info may be interesting.
The Joomla install is in /joomla while the other page is in /3.1
The .htaccess file however was in the root directory.
Edit02: I have managed to remove the wrong redirection. Question is: What is the correct way to redirect people from www.cyclingtoserve.at to /3.1? (without it showing up in the address)
Edit03: Here is a graphical representation (FTP) of the folder structure.
ftp
In order to avoid the redirect loop, you need to first check to see if your are already in the /3.1/ folder. Try this:
RewriteEngine On
RewriteCond %{REQUEST_URI} !^/3.1/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ http://%{HTTP_HOST}/3.1/$1 [L,R]
Sadly I've had to give up using .htaccess for the redirection.
I would have loved the recommended way (and still would like to know how).
Solution:
index.html in root has the following lines:
<frameset rows="100%" frameborder=0 framespacing=0 border=0>
<frame src="http://cyclingtoserve.at/3.1/" name="Content" noresize>
<noframes>
It may be the quick and dirty way of dealing with this issue, but it works.
If you can reproduce the same results with .htaccess, I'd love to tag it as an answer.

net::ERR_INCOMPLETE_CHUNKED_ENCODING

I use .htaccess to rewrite url from someurl.com/ to someurl.com/public/. First .htaccess in www root contains this:
DirectoryIndex ./public/
RewriteEngine on
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteRule ^(.*)$ ./public/$1 [QSA]
and second one in folder /public/ contains this:
DirectoryIndex _main.php
RewriteEngine on
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteRule ^(.*)$ ./?params=$1 [QSA]
And the problem is when I open url someurl.com/ without "public". Page is loaded correctly, but in Google Chrome console I got error: net::ERR_INCOMPLETE_CHUNKED_ENCODING. When I open url someurl.com/public/ page loads without any error.
Any ideas, please?
In my case, the problem was cache-related and was happening when doing a CORS request.
I post my response here cause this is the first resource I found on Google for net::ERR_INCOMPLETE_CHUNKED_ENCODING error.
Forcing the response header Cache-Control to no-cache resolved my issue:
[ using Symfony HttpFoundation component ]
<?php
$response->headers->add(array(
'Cache-Control' => 'no-cache'
));
I had this issue when trying to access some parts of the WP admin area, I managed to resolve it by adding the below to my functions.php file;
add_filter('wp_headers', 'wpse167128_nocache');
function wpse167128_nocache($headers){
unset($headers['Cache-Control']);
return $headers;
}
We had net::ERR_INCOMPLETE_CHUNKED_ENCODING problem in case of HTML, which contained too much empty lines. Some browsers had difficulties with interpretation of long files.
Once we made applied code cleaning in our templates by cleaning code from empty lines, all was perfect.
I was also facing same issue. Finally i got this was the permission issue on cache folder.
I decided changing the file : /etc/apache2/mods-enabled/cgid.conf
Adding the following code snippet:
<IfModule mod_cgid.c>
CGIDScriptTimeout 60
</IfModule>
This problem is really general, in my case I deactivated the WP Super Cache plugin, and didn't get the bug anymore, but this is so general that no one can really help you because of different configurations of servers/wordpress
In my case, the problem was the Windows anti-virus software (Kaspersky). Turning it off, the problem was gone :/
For me it was the Zend PHP Opcache. It had reached its memory limit and could no longer cache all scripts. This was a problem for a massive code base like Magento 2.
Increasing the memory limit solved the issue after weeks of banging head on desk.
It is about server side problem.
The user has running web service does not right access to web server cache folder.
Make sure nginx user can write to /var/lib/nginx (or /var/cache/nginx in some distros).
Make sure nginx user can write to the folder (find the nginx user form nginx configuration file is located usually in /etc/nginx/nginx.conf)
Give the right access (chown -R nginx:nginx /var/lib/nginx/)
Reload the service(-service nginx reload -in centos)

index.cfm append with SES URL in MURA

Recently working with MURA CMS with RAILO on UBUNTU. I am installing MURA in inner folder of root directory.
public_html >> website.
Following code added in .htaccess to rewrite URL to run website without index.cfm and website directory.
Options +FollowSymLinks
RewriteEngine On
DirectoryIndex index.cfm
RewriteRule ^$ /website/ [R]
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} !-d
RewriteRule ^website/([a-zA-Z0-9/-\s]+)$ /website/index.cfm/$1 [PT]
So my url http://example.com/website/privacy/ rewrite as
http://example.com/website/index.cfm/privacy/
I think rewrite rule should work correctly as I have tried some online validator and giving me correct result but if run it into MURA it produce URL like
http://example.com/website/index.cfm/privacy/index.cfm
I am not sure who is adding last index.cfm (apache or mura) and this take me to 404 page everytime.
Please help... this driving me crazy..
Thanks,
Pritesh
UPDATE
I have same site setup with windows/IIS 7 under subfolder of root and work fine though, if that help
To take off index.cfm of the URL, you have to edit file settings.ini.cfm
To edit this file
go to Modules / File manager
Then tab Application Root
Select folder config
Then right click on settings.ini.cfm and edit
In this file, siteidinurls and indexfileinurls have to be at 0
siteidinurls=0
indexfileinurls=0
After change, you have to reload application by clicking on Reload application on the Settings menu at the top of the window.
Thanks Matt and Mael for spending time for this issue.
Finally figure it out that TOMCAT was causing issue and adding index.cfm at the end.
<url-pattern>/website/index.cfm/*</url-pattern>
Add above URL pattern in web.xml file and it start working fine.

.htaccess - How to hide the internal directory used by subdomains?

I installed a small FTP space for my classmates which allows them to upload school related documents to my server. After the files have been uploaded, they can be easily accessed via a subdomain i.e. ftp.mydomain.com
Everything is working fine, the files can be downloaded and everything works properly.
There are two things which still annoy me though:
If you enter ftp.mydomain.com you see Index of /my_internal_directory instead of something like Index of /
Once you enter a sub-directory and click the Parent Directory link it will redirect you to ftp.mydomain.com/my_internal_directory/ as well
Is there any way to hide my_internal_directory ?
This is the content of my .htaccess file so far:
RewriteEngine on
RewriteCond %{HTTP_HOST} ftp\.mydomain\.com
RewriteCond %{REQUEST_URI} !^/my_internal_directory/
RewriteRule ^(.*)$ /my_internal_directory/$1 [L]
Any help would be greatly appreciated.
If you are using linux server then you can remove read permission for folder my_internal_directory
If not resolve, try to add:
Options -Indexes
on top of the file.
If still doesnt resolve please post your .htaccess file... :)

Resources