.htaccess not working properly(css not working) - .htaccess

I am trying to apply rewrite rules on my Web Page But When i try below code
then all external stylesheets not works e.g bootstrap
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^download/(.*).html$ search.php?q=$1 [L]
</IfModule>

Related

URLs Get redirected to root for webroot files

I have a CakePHP app that has some html static files in webroot.
HTML files are in some directories like webroot/dir1/dir2/page.html.
When I enter url: site.com/dir1 I get redirected to site.com/webroot/dir1/ but when I enter site.com/dir1/ I get redirected to the first page site.com
And If I enter url for the html file: site.com/dir1/dir2/page.html I get redirected to the first page site.com. It supposed to show the html file. How can I make it show html file and not redirect to first page?
In my public_html the htaccess is:
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^$ webroot/ [L]
RewriteRule (.*) webroot/$1 [L]
</IfModule>
In the webroot the htaccess is:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>
It's definitely not connected to CakePHP. Just ignore your directory / ies that should not be processed by CakePHP's routing system, see this related SO post.
Insert .htaccess into your directory/ies that should be ignored:
RewriteEngine Off
your questions isn't about php,
it's about the apache Webserver or more about -> Apache Module mod_rewrite
Rewrite Engine is only called one time, so you have to put all changes in one File.
kind regards
set

Redirection to Desired Url

I have a url like:
http://x.x.x.x/~mmi/
which maps to the public_html folder on my site. I have installed cakephp on my site. The default htaccess file for cakephp looks like below:
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^$ app/webroot/ [L]
RewriteRule (.*) app/webroot/$1 [L]
</IfModule>
I want to be redirected to:
http://x.x.x.x/~mmi/app/webroot/
instead of :
http://x.x.x.x/app/webroot/~mmi/
which is happening now. How should i modify htaccess file to get this desired result?
Following does the trick:
RewriteEngine on
RewriteRule ^~mmi/(.*)$ http://x.x.x.x/~mmi/app/webroot/$1

how to handle htaccess rewriteReule

i have WP site, and i have this htaccess:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^mypage/ /z____articles/mypage/ [R=301,L]
</IfModule>
this makes redirection in my browser, but i dont want to redirect, i want that the page:
site.com/mypage/
showed the content of
site.com/z____articles/mypage/
i tried to use these flags [NC,L] or [L] but none of them works..

Wordpress Rewriterule / Redirection

Guys i'm facing an issue regarding wordpress redirection.
I've used .htaccess on my website and i wish to make this work also for wordpress pages.I've installed wordpress in a folder named as "blogs" on the root like /blogs
I've also integrated/made changes in search.php of wordpress (domainname.com/blogs/wp-content/themes/my_theme/search.php) to my requirements. When someone searches the form action goes some thing like this:
http://www.domainname.com/blogs/?s=keyword
This works fine but I want to use rewrite rule over this something like:
www.domainname.com/blogs/blog-keyword with http://
but it brings user to 404.php page of wordpress
my current htaccess file contains the following code under the blogs directory of root:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /blogs/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /blogs/index.php [L]
# Pads Landing / Searching Page
RewriteRule ^blogs/movie-(.*) /pads/?s=$1
</IfModule>
# END WordPress
Kindly help me I've few mins left for project deadline.
Thanks in advance.
Ok...
Check into Options -Multiviews
I've noticed issues when using wordpress
I use it like so
Options +FollowSymlinks
Options -Multiviews
RewriteEngine on
So
RewriteRule ^pads/movie-([^/]+)$ "http://%{HTTP_HOST}/pads/?s=$1" [R=301,L]
Hope it works. Lemeknow

cakephp .htaccess with multiple domains

I have my cakephp .htaccess files set up as in the cookbook and everything is working fine.
My web site currently has multiple domains, all of which point to the same site (e.g. www.site.com, www.site.co.uk). I'd like to set up a rule so that requests to www.site.co.uk/page are permanently redirected to www.site.com/page, etc.
I'm having trouble getting both rules to work together. Can anyone help me out?
EDITED TO INCLUDE FURTHER DETAILS:
Here is the .htaccess file in my web root:
<IfModule mod_rewrite.c>
Options +FollowSymlinks
RewriteEngine on
# Force domain to be www.site.com
RewriteCond %{HTTP_HOST} !^www\.site\.com$
RewriteRule ^(.*)$ http://www.site.com/$1 [R=permanent,NC]
# For CakePHP
RewriteCond %{HTTP_HOST} ^www\.site\.com$
RewriteRule ^(.*)$ app/webroot/$1 [NC]
</IfModule>
I also have a separate CakePHP app in a subdirectory: tbgroup. Here is the .htaccess file (tbgroup/.htaccess):
<IfModule mod_rewrite.c>
RewriteEngine on
# For CakePHP
RewriteRule ^(.*)$ app/webroot/$1 [NC]
</IfModule>
Everything works as fine: www.site.co.uk is redirected to www.site.com, www.site.co.uk/page is redirected to www.site.com/page. CakePHP works fine. The only problem is www.site.co.uk/tbgroup is not redirected to www.site.com/tbgroup - it remains as www.site.co.uk/tbgroup (and CakePHP works fine).
Try it out on the live site if you like (www.site.com or www.site.co.uk).
I believe that you've pointed out the answer in the permanent redirection link in your question.
It's really not related to cakephp. It's just mod-rewrite issue. You have yo put this code in your .htaccess file (under /app/webroot)
rewritecond %{http_host} ^(www.)?site.co.uk [nc]
rewriterule ^(.*)$ http://site.com/$1 [r=301,nc]

Resources