homepage Welcome to WebmasterWorld Guest from 23.20.77.156
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Home / Forums Index / Code, Content, and Presentation / Apache Web Server
Forum Library, Charter, Moderators: Ocean10000 & incrediBILL & phranque

Apache Web Server Forum

This 33 message thread spans 2 pages: < < 33 ( 1 [2]     
move pages to a folder
helenp




msg:4562351
 1:24 pm on Apr 7, 2013 (gmt 0)

Hi,
wich is the easiest way to move pages to a folder with a 301?.
As the files will be moving place I suppose the only way to do is using the htaccess file, even if I dont like to touch it after all problems I had.
I suppose the rule should come after all rewrite rules I have for both http and https.

On the pages I want to move I have this at the top,
I assume I want need it anymore if I do a 301 to a http folder:
<?php header('Content-type: text/html; charset=utf-8');
if ( $_SERVER['HTTPS'] )
{
$host = $_SERVER['HTTP_HOST'];
$request_uri = $_SERVER['REQUEST_URI'];
$good_url = "http://" . $host . $request_uri;

header( "HTTP/1.1 301 Moved Permanently" );
header( "Location: $good_url" );
exit;
}
?>


Sorry for asking but Im afraid of touching the htaccess, after all that happened.

Is there a way not to do the redirection to /folder/new_page.php and just add /folder/

I want to move pages with the url similar, such as for example:
widgets_blue
widgets_red
etc.
And from domainroot to folder, and also from folder to another folder.
Not to do a rewrite rule for every page
is there a shorthand for
widgets_whatever.htm to /folder/widgets_whatever.htm
and also /folder/widgets_whatever.htm to /another_folder/widgets_whatever.htm

Thanks,

If needeed this is the rewrites rules I have:

AddType application/x-httpd-php5 .htm .html
RewriteEngine On

# REDIRECT htm INDEX PAGES to index/
RewriteCond %{SERVER_PORT} !^443$
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /([^/]+/)*index\.html?\ HTTP/
RewriteRule ^(([^/]+/)*)index\.html?$ http://www.example.com/$1 [R=301,L]
RewriteCond %{SERVER_PORT} ^443$
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /([^/]+/)*index\.html?\ HTTP/
RewriteRule ^(([^/]+/)*)index\.html?$ https://www.example.com/$1 [R=301,L]

# Get rid of extra path info such as example.com/pagina1.htm/maps/ etc
RewriteRule ^((?:[^./]+/)*[^./]+\.(?:html?|php))/ http://www.example.com/$1 [R=301,L]

# Redirect non-canonical to www
RewriteCond %{SERVER_PORT} !^443$
RewriteCond %{HTTP_HOST} !^(www\.example.com\.com)?$
RewriteRule (.*) http://www.example.com/$1 [R=301,L]
RewriteCond %{SERVER_PORT} ^443$
RewriteCond %{HTTP_HOST} !^(www\.example.com\.com)?$
RewriteRule (.*) https://www.example.com/$1 [R=301,L]

[edited by: coopster at 11:01 pm (utc) on Apr 8, 2013]
[edit reason] example.com was misspelled; fixed it [/edit]

 

helenp




msg:4563427
 9:01 am on Apr 10, 2013 (gmt 0)

htaccess isn't cached, because the browser doesn't download it. Only the page itself can be cached. The browser only "sees" htaccess when it makes a request.

Yes, but I had this problem once before, and the same happened, i used chrome and worked then cleaned firefox cache and like a charm. I did actualize the pages, that is normally enough. Could be the summertime maybe as sometimes since the change to summertime when I upload pages dreamveawer asks me if I really wants to do it as the one on host is newer, the hosts one has one hour more.

g1smd




msg:4563489
 1:10 pm on Apr 10, 2013 (gmt 0)

The problem is that Redirect Responses are cacheable. Once the browser knows a URL redirects, it does it automatically without checking the redirect is still in place on the server. That has confused me on many occasions.

helenp




msg:4563494
 1:26 pm on Apr 10, 2013 (gmt 0)

The problem is that Redirect Responses are cacheable. Once the browser knows a URL redirects, it does it automatically without checking the redirect is still in place on the server. That has confused me on many occasions.


That make sence, thanks.
If i had a wall I would put a note on it about it, so I remember it in some years when I have to touch the file again :)

This 33 message thread spans 2 pages: < < 33 ( 1 [2]
Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / Apache Web Server
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved