How to set a .page to be an index page/home page on a subfolder - teamsite

I am wondering if it's possible to set an index/home page in a subfolder.
So for example if I were to go to path site.com/subfolder/ my home.page would load automatically instead of having to type site.com/subfolder/home.page
Thank you for advice/help
Regards.

Yes this is possible if you front load a Web server to handle all incoming request. Add a URL handled to RewriteRule all request to /foldername/ to /foldername/index.page /foldername/home.page
Similar to Apache rule below.
RewriteRule ^/(puppies|canines)/(.*) /dogs/$2 [R]
RewriteRule ^/(.)/ /$1/index.page [R]
RewriteRule ^/(.)/ /$1/home.page [R]

Related

Issues with RewriteRule on Generic Anchor Redirect

I want to redirect any request to the root of my site to an anchor on the index. So
https://example.com/foo
Gets sent to
https://example.com/#foo
I've written this .htaccess file (it also redirects http requests to https, that part works, but is included for completeness)
RewriteEngine On
RewriteRule ^/(.*) /#$1 [NE,R=302]
RewriteCond %{HTTPS} !=on
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
Based on the discussion in this thread: mod_rewrite with anchor link this should work, but it's not matching for some reason. I tried out the rule given in that thread using this tool: http://htaccess.madewithlove.be/ and it doesn't seem to work there either.
I've tried clearing my cache and accessing in incognito mode, to no avail. Any help?

Apache rewrite condition for ajax crawling to pages with anchors

I have an AngularJS app on an Apache webserver that I would like to have indexed by search engines (i.e. Google/Bing bots etc.). I have a PhantomJS script to crawl and take snapshots of pages on my site, and I have followed the instructions from Google on how to redirect any http://mysite.com/?_escaped_fragment_=* requests to the appropriate pages.
The problem I'm facing is that I have a few routes in the app that change content based on the anchor, e.g. http://mysite.com/#!/about is different from http://mysite.com/#!/about#overview. I would like these changes to be indexed, but the hash character '#' is used for commenting and even escaping it with a backslash doesn't work. I have consulted other SO answers (e.g. Apache rewrite condition for ajax crawling and mod_rewrite page anchor), but I have not found instructions on how to deal with anchors.
I have two questions.
Is there a way to redirect URLs using mod_rewrite to snapshots that include anchors? For example, using the escaped version of '#' ('%23'):
http://mysite.com/?_escaped_fragment_=about%23overview => http://mysite.com/snapshots/about#overview.html
Here's what I currently have in my .htaccess file, though it does not work for pages with anchors:
RewriteEngine On
Options +FollowSymLinks
# Route for the index page
RewriteCond %{QUERY_STRING} ^_escaped_fragment_=/$
RewriteRule ^(.*)$ snapshots/index.html [NC,L]
# All other routes
RewriteCond %{QUERY_STRING} ^_escaped_fragment_=/?(.*)$
RewriteRule ^(.*)$ snapshots/%1.html [NC,L]
If (1) is not allowed, my idea on how to solve this problem is replace all '#' with '.' in the file names of the snapshots. Then I would need a mod_rewrite rule that would replace '#' with '.' in the escaped_fragment query parameter. Going back to my example, I currently have a rule that would take /?_escaped_fragment_=about#overview and reroute it to /snapshots/about.overview.html.
RewriteCond %{QUERY_STRING} ^_escaped_fragment_=/about%23overview$
RewriteRule ^(.*)$ snapshots/about.overview.html [NE,NC,L]
Is there a simple general rule I could use to implement this type of routing?
Any other ideas for how to solve this problem with general rewrite conditions would be appreciated, thanks!
I believe following rule should work for you:
RewriteCond %{QUERY_STRING} ^_escaped_fragment_=([^&]+) [NC]
RewriteRule ^$ /snapshots/%1.html? [R,NE,L]
It redirects /?_escaped_fragment_=about%23overview to /snapshots/about%23overview.html

IsapiRewrite rules generate strange pages/folders?

i'm using IsapiRewrite from helicontech for my custom classic ASP shopping cart.
My actual httpd.ini file is:
[ISAPI_Rewrite]
RewriteBase /
RewriteCond %HTTPS off
RewriteCond Host: (?!^www.domain.com)(.+)
RewriteRule /(.*) http\://www.domain.com/$2 [I,RP]
RewriteRule /httpd(?:\.ini|\.parse\.errors).* / [I,O]
RewriteRule /(.+)-([^-]*)-([^-]*)-([^-]*)\.html$ /detail.asp?brand=$1&model=$2&id=$3&lg=$4 [L]
So i'm actually using this component only to rewrite the product detail page in a nice way.
Lately looking in google cache i find some folders with files inside cached by googleBot that doesn't exist on my server eg: domain.com/carrera-CHAMPION ... and so on.
The page drawn if i access these strange pages is the detail.asp page but without css and some js loaded.
I tested recently the site with Acunetix scanner and seems like he found too these strange folders.
First i added a javascript check to se if Jquery not loaded then that means the page is one of these so i throw an alert and redirect user to homepage ..
Do you know what could be ? or how i could solve this via a rule in httpd.ini?
Hope i make myself clear if no feel free to ask me details,
thank you
Can you confirm that when you disable ISAPI_Rewrite these strange pages/folders disappear?
Please note that ISAPI_Rewrite only rewrites response headers and can't generate anything, so it's highly unlikely to be the cause of the issue.
BTW, your config is the mixture of ISAPI_Rewrite 2 and 3 syntax. If it's v2, please fix it like this:
[ISAPI_Rewrite]
RewriteCond %HTTPS off
RewriteCond Host: (?!www.domain.com).+
RewriteRule /(.*) http\://www.domain.com/$1 [I,RP]
RewriteRule /httpd(?:\.ini|\.parse\.errors).* / [I,O]
RewriteRule /(.+)-([^-]*)-([^-]*)-([^-]*)\.html$ /detail.asp\?brand=$1&model=$2&id=$3&lg=$4 [L]

dynamic subdomains with htaccess: URL shouldnt change in the browser

Trying to implement subdomains with htaccess.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} !^www.
RewriteCond %{HTTP_HOST} ^([a-z0-9]+)\.domain.com(.*)$
RewriteRule ^(.*)$ http://domain.com/index.php?/public_site/main/%1/$1 [L]
</IfModule>
when i enter ahser.domain.com the browser URL is changing. is there a htaccess option to not let this happen when absolute URLs is used in RewriteRule?
Don't rewrite to a full URL with domain in it. That generates a redirect since it's going to a different website! You could put microsoft.com there; so how would it work without redirecting?
What you have to do is make sure that the web pages work under the original domain. So when the client asks for myname.domain.com/... how about rewriting that to myname.domain.com/index.php?public_site/main/myname/.... Keep the domain the same. The index.php? can be made to work in any of those domains. For instance, even this could work:
http://OTHER.domain.com/index.php?public_site/main/MYNAME/...
I.e. set it up so it doesn't matter which virtual host accesses that path.
Once you have that, the rewrite can then just do:
# will not trigger redirect
RewriteRule ^(.*)$ /index.php?/public_site/main/%1/$1 [L]
You have to be careful not to introduce a loop since you're now redirecting a URL to a longer URL which matches the same rewrite rulethe same domain. You need an additional RewriteCond not to apply this rewrite if the URL already starts with /index.php?public_site/.

URL rewriting problem

In order to convert dynamic URLs on my site www.kitesmovie.co.in to static urls. Eg: www.kitesmovie.co.in/stories.php?id=10 to www.kitesmovie.co.in/Barbara_Mori_Hrithik_Roshan_New_Movie.
I tried using rewriting rules in my htaccess files, but it did not work. Please tell me how to do this.
Thanks a lot in advance.
It's not really clear what you are trying to achieve.
When you say "convert dynamic urls to static urls", do you really want to have user to type in the ...?id=10 and the file named Barbara_Mori_Hrithik_Roshan_New_Movie lives on your server? I think, it's the opposite way - you want to let the user type in the long & nice title and actually resolve it to ?id=10
If this is the case, the #Mike's answer is nearly correct, you only have to swap the parts of the last line:
RewriteRule Barbara_Mori_Hrithik_Roshan_New_Movie stories.php?id=10 [R,L]
Another question - are you sure you have the .htaccess working? An easy way to check is to set the contents of .htaccess to
order deny, allow
deny from all
And see if you can still access that directory. If you can, this means the "deny from all" does not work. Then check your apache config - is .htaccess allowed in the particular virtualhost and/or directory.
Lots of missing info there. If you are using apache with mod_rewite installed, place this in your .htaccess:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule stories.php?id=10 Barbara_Mori_Hrithik_Roshan_New_Movie [R,L]
</IfModule>
You might want to have a look at this article: http://www.addedbytes.com/for-beginners/url-rewriting-for-beginners/
Generally, you would use a RewriteRule something like this:
RewriteRule ^stories.php?id=10$ Barbara_Mori_Hrithik_Roshan_New_Movie [R=301,L]
If that's not working for you, then feel free to add more details to your question.

Resources