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?
Related
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'm using a justhost.com host for my joomla 3.* website. I have been building my website in a subdirectory of the public www folder. Everything was working fine, until I "published" the website to the root folder of the domain. I had to modify the $live_site variable to point to the root of the domain and place an .htaccess file there in order for my subdirectory to not appear in the url. After I did this everything keeps working but I cannot login from the back-end. After I click the "login" button, the resolved domain points to "administrator" from the root folder and therefore it can't find the administrator component.
Speaking more practically:
this is my domain:
http://mydomain.com
which is mapped to this folder on the server:
.../www/
this is the subdirectory in which I built the website:
.../www/mydomain.com
I added the following lines to .../www/.htaccess:
RewriteCond %{HTTP_HOST} ^(www.)?mydomain.com$
RewriteCond %{REQUEST_URI} !^/mydomain.com/
RewriteRule ^(.*)$ /mydomain.com/$1
RewriteCond %{HTTP_HOST} ^(www.)?mydomain.com$
RewriteRule ^(/)?$ mydomain.com/index.php [L]
And I modified .../www/mydomain.com/configuration.php:
$live_site = 'http://www.mydomain.com';
After all this, I can reach http://mydomain.com/mydomain.com from http://mydomain.com/, but when I try logging in from http://mydomain.com/mydomain.com/administrator/index.php it resolves to http://mydomain.com/administrator/index.php and therefore it doesn't let me log in.
I hope this is clear.
Any help would be greatly appreciated.
Thank you
I found the solution. It took one more line in .../www/.htaccess
RewriteRule ^administrator/(.*)$ /mydomain.com/administrator/$1 [L]
Check Your User Name and Password
In Joomla after you put in your server and if your server system setting is old far it does not respond Warning
''The combination of username and password is not correct or you do not have an account."
so check that!!! for exemplify Check the site esche.org.et and enter a user name and password it does not respond the warning instead go to esche.org.et/index.php but i manage that website with the correct password and user name it will lead you to administrator console.
I have setup two domains to point to the same hosting server. For eg: the domains be :
example1.com
example2.com
I have created a directory called 'home' in my root, and whenever the 2nd domain is accessed, it should get redirected to the home directory.
For eg: example2.com/post.php should get redirected to example2.com/home/post.php
I have done this by creating an htaccess file in my root directory with the following contents:
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{HTTP_HOST} example2.com$ [NC]
RewriteCond %{REQUEST_URI} !home
RewriteRule ^(.*)$ ./home/$1
This is working perfectly. Now, i have a second requirement where i need to redirect users to a php file (post.php) inside home directory whenever the user accesses the url example2.com/gallery/somestring.
So, i created a second htaccess file in my home directory and entered the following code:
Options +FollowSymLinks
RewriteEngine On
RewriteRule ^gallery/([^/]+)$ post.php?post=$1
But, whenever i try to access the url example2.com/gallery/somestring, it shows a strange 404 Not Found error :
The requested URL /home/redirect:/home/gallery.html/somestring/somestring was not found on this server.
Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.
Here. "redirect:" string is getting concatenated to the redirected URL somehow.
Can any one please give me some idea as to why its happening ??
I solved this problem. I am sharing this if any one gets into this same problem and finds this post. The problem was that there was a file gallery.html in my root folder. This was causing this error. Just delete this file or rename the file to some thing else. Thats it :)
Several companies are sharing resources (wiki, forum, shops...), now they like to use ONE server certificate for this.
The url looks as following:
company1.domain1.com or www.company1.domain1.com
company2.domain2.com or www.company2.domain2.com
company3.domain3.com or www.company3.domain3.com
New pointing to the same newdomain.com/company1 on the hosting.
What I want to achieve at the end is:
newdomain.com/company1
newdomain.com/company2
newdomain.com/company3
In the browser when somebody type www.company2.domain2.com in the URL you should see http://newdomain.com/company2 (without www)
I need two examples. One is exactly this thing I described. Second is the same thing, but at the end in URL I want see https://newdomain.com/company2 (without www)
In the htaccess file in your domain1.com, domain2.com, domain3.com, etc, document root, add:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^(www\.)?([^.]+)\.[^.]+\.com$ [NC]
RewriteRule ^(.*)$ http://newdomain.com/%2/$1 [L,R=301]
This will redirect http://www.mycompany.somedomain.com/path/to/file.txt to http://newdomain.com/mycompany/path/to/file.txt
I'm having some trouble in finding an answer for a 301 redirect problem. The story goes like this:
I used to have a German language news site at www.punkto.ro. Every new article created with the site's CMS had the form: punkto.ro/articles/title-1234.html, where the 1234 is replaced by the article's number in the database.
For several reasons I had to redesign and opted for wordpress, which I placed in the root. I created a subdomain archive.punkto.ro and replaced the url variable "punkto.ro" in a config.php file with "archive.punkto.ro". Then I moved the site files to the subdirectory "archive". It works fine.
Of course, old article links in google now lead to a 404 response. To be sure, I also indicated the location of the archives on the 404, so people can go look there.
Now to the redirect: what I want to achieve is that when a user clicks a link in google punkto.ro/articles/title-1234.html, he/she should be redirected to archive.punkto.ro/articles/title-1234.html.
The strange stuff is that I can't find the folder "articles" in my file manager (cpanel OR ftp)... Does anybbody have any idea as to how the .htacces should look like?
Examples:
Old link: http://www.punkto.ro/articles/Staatschef_Basescu:_Rumaenien_einschliesslich_gesetzmaessig_fuer_Grexit_gewappnet-4169.html
New link: http://www.archive.punkto.ro/articles/Staatschef_Basescu:_Rumaenien_einschliesslich_gesetzmaessig_fuer_Grexit_gewappnet-4169.html
I don't think you have to create the .htacccess-file in the "articles"-folder. Just create it in the main folder.
I hope this will work for you:
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^(www\.)?punkto.ro$
RewriteRule ^articles/(.*)$ http://www.archive.punkto.ro/articles/$1 [L,NC,R=301]
The RewriteCond makes sure that www.archive.punkto.ro will not be redirected again, the RewriteCond redirects every URL containing "articles/" to the archiv.