i need redirect domain in .htaccess in root on server.
My .htaccess:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^(www\.)?domain\.com$ [NC]
RewriteCond %{REQUEST_FILENAME} !/yii/projectName/
RewriteRule ^(.*)$ /yii/projectName/$1 [L]
Home page application works, but url manager doesn't work, it always redirects to home page.
My urlManager:
'urlFormat'=>'path',
'showScriptName'=>false,
'rules'=>array(
...
),
Thank you for your help
Try this:
RewriteEngine on
# if a directory or a file exists, use it directly
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# otherwise forward it to index.php
RewriteRule . index.php
I found this alternative solution a year ago here: http://www.yiiframework.com/wiki/214/url-hide-index-php/
EDIT:
URL manager settings seems to be OK, but be sure to add these rules AFTER your custom url rules:
'rules'=>array(
// ... add you custom url rules here, if there are any
// Home page
'/' => 'info/index', // edit this to your home page controller/action
// Default patterns for any other controller/actions.
// These are checked last, if there were no applicable custom rules for a specific URL
'<controller:\w+>/<id:\d+>' => '<controller>/view',
'<controller:\w+>/<action:\w+>/<id:\d+>' => '<controller>/<action>',
'<controller:\w+>/<action:\w+>/*' => '<controller>/<action>'
),
Related
Good day,
I want to rewrite my user id URL to a physical page on my website.
This is a login PHP MySQL system and each user (client) has an ID assigned to them in MySQL. I want to give each user (client) a unique home page
So the client list are as follow:
Client1 - Client ID = 341
Client2 - Client ID = 342
Client3 - Client ID = 343
Currently, the user login to the site and gets redirected
from:
http://localhost:8888/report.mark1/user.php?id=341
to:
http://localhost:8888/report.mark1/341 (this works perfectly)
But I want to change this to the following:
From: http://localhost:8888/report.mark1/341
To: http://localhost:8888/report.mark1/client1/home
I want to do this for the other clients as well:
From: http://localhost:8888/report.mark1/user.php?id=342
To: http://localhost:8888/report.mark1/client2/home
From: http://localhost:8888/report.mark1/user.php?id=343
To: http://localhost:8888/report.mark1/client3/home
this is the current .htaccess file code:
RewriteEngine ON
RewriteBase /report.mark1/
##External redirect change of URL rules here.
RewriteCond %{THE_REQUEST} \s/(report\.mark1)/user\.php\?id=(\d+)\s [NC]
RewriteRule ^ /%1/%2? [R=301,L]
##Internal rewrite to user.php rules here.
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(?:[^/]*)(\d+)/?$ /report.mark1/user.php?id=$1 [QSA,L]
I hope this helps a bit more :)
With your shown samples, attempts please try following .htaccess rules. Make sure your .htaccess file is present alongside with report.mark1 folder and your user.php is present inside report.mark1 folder.
Make sure to clear your browser cache before testing your URLs.
RewriteEngine ON
RewriteBase /report.mark1/
##External redirect of url in browser rules here...
RewriteCond %{THE_REQUEST} \s/(report\.mark1)/user\.php\?id=(\S+)\s [NC]
RewriteRule ^ /%1/%2/home? [R=301,L]
##Internal rewrite of url to user.php file here...
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(?:[^/]*)/([^/]+)/.*/?$ /report.mark1/user.php?id=$1 [QSA,NC,L]
I have this URL:
http://www.register.abc.com/myapp/administrator/registration
Which is :
http://www.register.abc.com is my domain
myapp is my aplication folder in server
administrator/registration is my controller and function
What I'd like to do is to remove this part /myapp/administrator/registration from my URL. In default, when user only enter the http://www.register.abc.com/ it will be redirected to my home page. I'd like to set it so the user directly enter registration page not the home page. I have little to no knwledge about .htaccess. Any help is greatly appreciated.
Note: I am using wiredesignz codeigniter modular extensions hmvc
Edit:
my current .htaccess is like this:
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase /myapp
RewriteCond $1 !^(index\.php|resources|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]
</IfModule>
In your site root .htaccess (a level above myapp/ you may try this .htaccess code:
RewriteEngine On
RewriteRule ^$ myapp/administrator/registration [L,R=302]
If you want an internal rewrite (without changing URL) then try:
RewriteRule ^$ myapp/administrator/registration [L]
How can I make a wildcard subdomain with codeigniter? I have try anything on google and this site. But it wont work, if not 500 error page it will return nothing (I mean no effect) because I got this on my .htaccess before :
<IfModule mod_rewrite.c>
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php/$0 [PT,L]
</IfModule>
I think it always conflict with that one above, btw what I desired to be is :
example.com/page => example.com/page (without subdomain will just be normal, with no www and no index.php)
abc.example.com => example.com/abc-channel
exc.example.com => example.com/exc-channel
abc.example.com/my/foo/page => example.com/abc-channel/my/foo/page
All will generated with no redirect.
I've notice in firebug that the non-www version of my magento store redirects to the www version using 302. For SEO purposes I want it to redirect using 301.
How I tried to fix it
I went to the System > Configuration > General > Web > Url Options and my setting Redirect to Base URL if requested URL doesn't match it is set to Yes (there are only 2 options: Yes or No)
Imporantant notes
I'm using Magento v1.4.0.1
My .htaccess file contains the following, in regards to URL Rewrites:
<IfModule mod_rewrite.c>
Options +FollowSymLinks
RewriteEngine on
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteCond %{REQUEST_URI} !^/(media|skin|js)/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule .* index.php [L]
</IfModule>
How can I change the redirect method to 301?
As of 1.6.2.0 there seems to be an option to select the redirect method in the Admin Panel, no need to modify the .htaccess.
Simply go to System -> Configuration -> Web -> Url Options and set Auto-redirect to Base URL to your preferred method.
Try changing the last line to this:
RewriteRule .* index.php [R=301,L]
See Apache mod_rewrite RewriteRule Directive the section about flags.
I have a cakePHP app working at http://domain1.com/domain2, and want to point http://domain2.com/ to this application.
I have done this change the document root of domain2 to public_html/domain2, but, when I go to: domain2.com all css, javascript and images are not loaded, with a message saying controller not found.
What I can do?
All domains have a folder with their domains without the TLD at domain1.com, I think if I create a htaccess and get the domain without TLD, and finally change rewriteBase, will work as expected, but don't know how to do this.
Current htaccess of domain2:
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php?url=$1 [QSA,L]
You can try adding an htaccess file in domain2's document root with the following rules:
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} \.(css|js|png|jpe?g|gif|bmp|ico)$ [NC]
RewriteRule ^/?domain2/(.*) /$1 [L,PT]
This should remove the domain2 part of the links.