In the yii2 advanced application, need to show admin instead of backend/web and default route to this admin url.
http://localhost/yapp/backend/web/site/index to http://localhost/yapp/admin/site/index and when running application it should redirect to http://localhost/yapp/admin
From Yii wiki https://www.yiiframework.com/wiki/799/yii2-app-advanced-on-single-domain-apache-nginx
to achieve /admin in your url.
// backend/config.php
components' => [
....
'request'=>[
....
'baseUrl'=>'/admin',
],
....
],
and apache rewrite rule
# .htaccess
# Handle the case of admin, skip ([S=1]) the following rule, if current matched
RewriteRule ^admin(/(.*))?$ backend/web/$2 [S=1]
Related
I have a multi-user website which generates user profiles.
By default, the profiles as set to the users' id, e.g. mysite.com/userid
I'd like to be able to change that to the username instead, and place it on the subdomain, e.g. username.mysite.com
Both the id and username are unique in mysql so there will be no duplicate issues.
But I'm struggling to find a way to do this.
I consulted this article: How to let PHP to create subdomain automatically for each user?
Which gave me some idea on how to start, but technically I'm lost.
I added the subdomain *.mysite.com, and tried the following in my .htaccess file:
Options +FollowSymLinks
RewriteEngine On
RewriteRule ^([^a-zA-Z0-9-]*)$ profile/?id=$1
RewriteCond %{HTTP_HOST} ^(^.*)\.mysite.com
RewriteRule (.*) profile/?id=%1
Where "mysite.com" is my actual site. But it produced 404 errors.
Inside my index.php is the following line for seo profile pages:
$router->map(get_option('profile-seo-url','/profile/:name/:id/:section'), 'profile', array('methods' => 'GET,PUT,POST', 'filters' => array('id' => '(\d+)','section' => '(.*)')));
Is this overriding the htaccess file?
How to change the url of opencart from index.php?route=account/login to login and
index.php?route=account/register to register
Check out this plugin:
SEO Complete plugin
go to admin panel --> setting--> Use SEO URLs - Yes. Rename .htaccess.txt file to .htaccess
apache module mod-rewrite must be installed on server
you can also change the url by adding new rewrite rule
ie:
RewriteRule ^login/?$ index.php?route=account/login [L] #login page
and add the link ie www.example.com/login
like wise you can do it for the register
my problem is solved by doing.
I currently have a Geo-redirect set up in my htaccess to redirect user say from Asia who visits example.com to asia.example.com. I am now wondering how to override that redirection so users from asia.example.com can get to example.com through a link on asia.example.com.
Is that possible or do I have to use a client-side redirect and how would I go about setting that up.
And some background info example.com is running Magento and asia.example.com will be a landing page for now.
Thanks
Update: My host says I should install this https://github.com/maxmind/GeoIP2-php on Magento... How would I do that?
Update from comment:
# Redirect multiple countries to a single page
RewriteEngine on
RewriteCond %{ENV:GEOIP_COUNTRY_CODE} ^(VN|SG|CN|MY|JP|KP|KR)$
RewriteRule ^(.*)$ asia.example.com$1 [R,L]
Normally Magento offers a store switcher in the form of a select field, see it working on demo.magentocommerce.com. The theme in use might change how this is displayed, it could be a link or button instead but the principle is the same, a store cookie is written with the store code as it's value. We can test for that directly in .htaccess and avoid GeoIP if present.
# Redirect multiple countries to a single page
RewriteEngine on
RewriteCond %{ENV:GEOIP_COUNTRY_CODE} ^(VN|SG|CN|MY|JP|KP|KR)$
# New cookie condition goes here
# ! means true when it doesn't match
# \b means word boundary
RewriteCond %{HTTP_COOKIE} !\bstore=default\b
RewriteRule ^(.*)$ asia.example.com$1 [R,L]
It is necessary for the cookie to be transmitted on every request or the user might find themselves being redirected later. You may have to set the cookie domain to .example.com (note the leading period) if it misbehaves. You can do this in Magento's admin under System > Configuration > Web > Session Cookie Management. This allows the cookie to be written by asia.example.com and be read by example.com, and vice versa.
If you want to make a link instead of the store switcher then use Mage::getUrl in this way, it will generate an URL with a ___store query parameter:
<?php
$url = Mage::getUrl('', array(
'_store' => 'default',
'_store_to_url' => true
));
?>
<?php echo $this->__('International Store') ?>
I have a serious problem about routing and envirenement or module in symfony 1.4,so I created three modules frontend , mobile and backend.
So in frontend and mobile module,I'm using almost the same routing :
//apps/frontend/config/routing.yml
home:
url: /home
param: { module: user, action: home }
homepage:
url: /
param: { module: content, action: index }
....
default_index:
url: /:module
param: { action: index }
default:
url: /:module/:action/*
mobile module :
//apps/mobile/config/routing.yml
home:
url: /home
param: { module: user, action: home }
homepage:
url: /
param: { module: sfGuardAuth, action: signin }
....
default_index:
url: /:module
param: { action: index }
default:
url: /:module/:action/*
I use the link to access to my site
mysite.com/ ==> frontend module(frontend.php)
mysite.com/mobile.php ==> mobile module(mobile.php)
The problem is when I access to mobile version to login page correctly but after login they redirect me to homepage of frontend module not to the home page of mobile module?
Remark :
when I use this link mysite.com/mobile_dev.php with dev env the mobile version works very fine!
Edit :
here is my htaccess :
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{QUERY_STRING} ^(%2d|-)[^=]+$ [NC]
RewriteRule ^(.*) $1? [L]
</IfModule>
Options +FollowSymLinks +ExecCGI
<IfModule mod_rewrite.c>
RewriteEngine On
# uncomment the following line, if you are having trouble
# getting no_script_name to work
RewriteBase /
# we skip all files with .something
#RewriteCond %{REQUEST_URI} \..+$
#RewriteCond %{REQUEST_URI} !\.html$
#RewriteRule .* - [L]
# we check if the .html version is here (caching)
RewriteRule ^$ index.html [QSA]
RewriteRule ^([^.]+)$ $1.html [QSA]
RewriteCond %{REQUEST_FILENAME} !-f
# no, so we redirect to our front web controller
RewriteRule ^(.*)$ index.php [QSA,L]
</IfModule>
So when I change index.php to mobile.php the link mysite.com/mobile.phpgo directly to to mobile version homepage and all works fine...
So my issue now is how to edit my .htaccess to redirect me like this :
mysite.com/index.php or mysite.com/ redirect me to my site
mysite.com/mobile.php redirect me to mobile version
Edit2 :
I explain you,when I start with this link mysite.com/mobile.php so it redirect me to mobile apps to login page but when after login instead it go to my homepage the new request search default front controller and it point on index.php so that give me the homepage of frontend apps not the mobile apps!
So why symfony with mobile_dev.php keep in memory it all time that we are in mobile dev env and with mobile.phpit switch me from prod mobile env to frontend prod env in first redirection?
The sfGaurdModule redirects to route homepage after successful login. Your homepage route in both apps have a URL defined as /. So when you login to frontend or mobile you are redirected to http://mysite.com/.
As one URL can only describe one resource there is no way your web server can understand which application you want to use when it gets the URL http://mysite.com/. It looks into .htaccess and sees that it should treat this URL as referring to http://mysite.com/index.php (frontend application). That's why you get redirected to frontend all the time.
There is nothing you can do with .htaccess to change it as you will never be able to differentiate just the URL http://mysite.com/.
What you can do is:
either change the URL of the homepage for mobile app to e.g. /mobile_home and switch no_script_name to false for the mobile app
or overwrite the signin() function of the sfGuardAuth module so it will redirect to different pages based on the application you now use.
Either way remember to set no_script_name to false in one of your apps as it will always cause a problem if you don't do this.
As for the dev environment. It works because after login in dev you are never redirected to / but either to frontend_dev.php or mobile_dev.php so the server does not get confused.
Be careful, you cannot use 2 times no_script_name: true (for your frontend and mobile apps), only once if it's on the same domain/subdomain!
You may want to look into relative_url_root, I also had an issue with this: Symfony does not detect relative url root.
If you're using sfGuardPlugin or sfDoctrineGuardPlugin you have to check the plugin code to modify the redirect behavior. sf 1.4 have poor multiple app support. And just to clarify you have created three "apps" not three "modules", as you said.
I need to redirect the user using htaccess to www.xyz.com/some_folder_name/custom_page.php if the user enters www.xyz.com/some_folder_name/ , in the browser, that is, in the situation, when no specific php page has not been specified.
Any suggetions?
You can use the following configuration:
RewriteRule ^some_folder_name/?$ /some_folder_name/custom_page.php [L,R=302]
If you want the redirection to be a permanent one, change 302 into 301.
Or you can add your custom_page.php as default index page
DirectoryIndex custom_page.php ...