I need to do 301 redirect to my root url And all the links below the ROOT will work as usual
e.g redirect https://mysuddomain.yyy.com to https://www.sitename.com
Related
I got a server running on http. With reverse proxy I was able to wrap it into https and server it as https.
The http server runs on port 9000 and expects the GET parameter action.
So with this config, I can wrap my http in https:
SSLEngine On
Include /etc/letsencrypt/options-ssl-apache.conf
SSLCertificateFile /etc/letsencrypt/live/example.com/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/example.com/privkey.pem
SSLCertificateChainFile /etc/letsencrypt/live/example.com/chain.pem
SSLProxyEngine On
ProxyPass /snapshot/ http://localhost:9000/
ProxyPassReverse /snapshot/ http://localhost:9000/
However I still want to redirect from /snapshot/ to a query parameter after a slash:
https:// example.com/snapshot/ -> https:// example.com:9000/?action=snapshot
I can't get my head around this redirection. I tried some RewriteRule but only could get it to get redirected to /snapshot?action=snapshot.
Please be aware that the parameter should be after the slash and that the URL shouldn't display the action parameter.
How do I manage this?
Using the RewriteRule instead of the ReverseProxy did the trick. Replacing the SSLProxyEngine On lines with these lines works for me:
RewriteEngine On
RewriteRule snapshot/ http://localhost:9000/?action=snapshot [P]
RewriteRule stream/ http://localhost:9000/?action=stream [P]
Hello and thanks ahead of time for the help.
I have a blog on my old site and I'm trying to 301 redirect all of the posts to their new location on my new site using haproxy. For example, I want https://www.oldsite.com/john-blog/blogpost1 to be 301 redirected to https://www.newsite.com/jill-blog/blogpost1.
https://www.oldsite.com/john-blog => https://www.newsite.com/jill-blog
frontend https
option http-server-close
reqadd X-Forwarded-Proto:\ https
acl is_ob path_sub john-blog
redirect location https://www.newsite.com/jill-blog code 301 if is_ob
I've figure out how to forward traffic for /john-blog but haven't been able to figure out how to do the rewrite so that /john-blog/blogpost1 on the old site 301s to /jill-blog/blogpost1 on the new site.
This is what I was able to come up with:
frontend https
option http-server-close
reqadd X-Forwarded-Proto:\ https
acl old_site hdr(host) -i www.oldsite.com
acl john_blog path_beg /john-blog
acl jill_blog path_beg /jill-blog
reqrep ^([^\ ]*\ /)john-blog(.*) \1jill-blog\2 if old_site john_blog
redirect prefix https://www.newsite.com code 301 if old_site jill_blog
The only downside of this config is that it will also redirect https://www.oldsite.com/jill-blog => https://www.newsite.com/jill-blog. If this is an issue I can try and figure something else out.
How is works
I will follow and example for a request to https://www.oldsite.com/john-blog/blogpost1.
In this example acl old_site would be true, acl john_blog would be true and acl jill_blog would be false.
The reqrep line replaces john-blog with jill-blog only if both the old_site and john_blog acls are true, which for this example is the case. After this line the example url would be https://www.oldsite.com/jill-blog/blogpost1.
At this point acl john_blog is now no longer true but acl jill_blog is as the uri now begins with /jill-blog. acl old_site is still true.
The redirect line is in prefix mode where the redirect location is determined by the provided string with the original uri appended. In this example the provided string is https://www.newsite.com and the uri that gets appended is /jill-blog/blogpost1 resulting in a reditect url of https://www.newsite.com/jill-blog/blogpost1.
Hope that helps.
I am working on magento 1.7 version.
I have a store on domain say domain1.com and it is working.
Now I want add another domain as a multiple store say domain2.com
I created website,store,storeview from admin and change base url of newly created store(domain2.com).
I copied index.php and .htaccess file from domain1.com to domain2.com root folder.
And add following lines in .htaccesss file of domain2.com:-
SetEnvIf Host www\.domain2\.com MAGE_RUN_CODE=domain2
SetEnvIf Host www\.domain2\.com MAGE_RUN_TYPE=website
SetEnvIf Host ^domain2\.com MAGE_RUN_CODE=domain2
SetEnvIf Host ^domain2\.com MAGE_RUN_TYPE=website
And index.php file of domain2.com is:-
$mageFilename = MAGENTO_ROOT . '/app/Mage.php';
But when I run domain2.com it gives me error like:-
/home/httpd/vhosts/domain2.com/httpdocs/app/Mage.php was not found
Please help me sort out this problem.
This sounds like a hosting issue - domain2.com doesn't look to be pointing to the same folder as domain1.com.
You can link folders on linux like this:
$ cd /home/httpd/vhosts/
$ ln -sf domain1.com domain2.com
Can't see the front end of my wordpress localhost.
The process I've done:
1. I installed wordpress locally with BitNami on Mac OX.
2. imported an existing data base to the phpmyadmin.
3. changed the wp-config file to support the local host database.
4. added these two lines
define('WP_HOME','http://localhost/wordpress');
define('WP_SITEURL','http://localhost/wordpress');
5. logged in to my wp-admin.
Now I can see the site's WP-ADMIN and do things in it BUT I cannot view the front end.
whenever I try i get:
can't establish a connection to the server at 127.0.0.1.
or if i try to view a post i get
"The requested URL /site/2013/02/13/idho_global/ was not found on this server."
If I'm trying to preview a draft I see it the way it should appear.
any help?
Check the database via phpmydmin and change the url if you didn't do it.
In the wp_options check if siteurl & home are set to localhost
Update : you should have a look to the 'Moving Wordpress page' https://codex.wordpress.org/Moving_WordPress
It explains very well ho to change permalinks and things to do after moving a Wordpress.
If your permalinks don't works, check if you have a .htaccess in the root directory. The content should be :
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
You need to update the database urls. Wordpress hardcodes them. Run the sql below replacing "old-url.com/wordpress" and "new-url.com/wordpress" with your urls
UPDATE wp_posts SET guid = REPLACE(guid, 'old-url.com/wordpress', 'new-url.com/wordpress');
UPDATE wp_posts SET post_content = REPLACE(post_content, 'old-url.com/wordpress', 'new-url.com/wordpress');
UPDATE wp_options SET option_value = REPLACE(option_value, 'old-url.com/wordpress', 'new-url.com/wordpress');
The most succinct way of summarizing the problem at hand:
Development is over, and everything was run against frontend_dev.php during development and testing
This means that all URLs were: server.com/frontend_dev.php/module/action/parm
Moving to production means switching environments, and thusly using index.php instead
server.com/index.php/module/action/parm
Part of moving to production is using mod_rewrite under Apache2 to make the “index.php” part of the URL vanish, but still be functioning
server.com/module/action/parm is still routed against index.php
The URLs are indeed appearing w/o the index.php part, but symfony routing is now complaining:
ie, server.com/goals which routes to goals/index
-- perfectly fine using frontend_dev.php or index.php as an explicit controller
server.com/index.php/goals
-- using no explicit controller (via rewrite):
[Tue Dec 14 12:59:51 2010] [error] [client 75.16.181.113] Empty module and/or action after parsing the URL "/goals/" (/)
I have verified the rewrite is indeed routing to index.php by changing the rewrite to something that doesn’t exist:
[Tue Dec 14 13:05:43 2010] [error] [client 75.16.181.113] script '/opt/www/projects/adam/web/index2.php' not found or unable to stat
I have tried rerouting to frontend_dev.php, but only am provided with more debug information from symfony, none of which is helpful:
404 | Not Found | sfError404Exception Empty module and/or action after parsing the URL "/goals/" (/).
stack trace
1. at () in SF_SYMFONY_LIB_DIR/controller/sfFrontWebController.class.php line 44 ...
2. at sfFrontWebController->dispatch() in SF_SYMFONY_LIB_DIR/util/sfContext.class.php line 170 ...
3. at sfContext->dispatch() in SF_ROOT_DIR/web/frontend_dev.php line 13 ...
I have tried the using the RewriteBase option in .htaccess, but that does not help any, nor changing the true/false in the configuration line of the controllers
I hope this provides enough to understand why we’re confused, and able to direct us to a resolution.
Following is the current .htaccess and index/frontend configuration lines
Index.php:
$configuration = ProjectConfiguration::getApplicationConfiguration('frontend', 'prod', false);
Frontend_dev.php:
$configuration = ProjectConfiguration::getApplicationConfiguration('frontend', 'dev', true);
.htaccess:
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]
I had similar issue and setting 'AllowOverride' to ALL for Symfony's WEB folder in Virtual Host's config sorted out this problem.
Welcome to Stack Overflow.
Maybe you're confusing the "index" route with "index.php"?
These URLs should theoretically all work.
server.com/frontend_dev.php/goals/index
server.com/index.php/goals/index
server.com/goals/index
server.com/goals
I can't remember if the trailing slash, like server.com/goals/, works or not. There's a gotcha there.