.htaccess not working in subfolder - .htaccess

I have a couple of sites that are currently under development and I've put them under a specific subfolder for clients/co-workers to view - "http://dev.staffanestberg.com/site-name/". I've run into some problems getting the sites working with .htaccess. I can reach the index page by typing in the url for a site folder but neither img/style/js/etc linking or page rewriting works. Looking for a solution to this, Apache's "RewriteBase" seems to be the most likely one, however I can't get it to work.
Tried
RewriteBase http://dev.staffanestberg.com/site-name/
RewriteBase /site-name
What would be the correct method?
Thanks in advance,
-Staffan

mod_rewrite’s RewriteBase directive does only apply to rewrites using RewriteRule. And that does only apply for requests that are sent to the server.
But if the requested URIs are already wrong, RewriteBase doesn’t do any help. What you could try instead is the HTML element BASE that set’s the base URI for the current document.

Related

How do you rewrite a URL with a query in a subdirectory using .htaccess

I'm building a website (no frameworks) and I have a .htaccess file in my root with working rewrite engine. I've been searching far and wide for a solution for my problem but nothing seems to work.
I'd like my site url to be displayed as: mysite.com/profile/profilename
and for it to be rewritten to: mysite.com/profile.php?name=profilename
so to give the illusion of there being another subdirectory when there isn't.
I've done a tonne of research and this seems to be the most logical to me but it doesn't seem to work:
DirectoryIndex index.php
RewriteEngine On
RewriteRule ^profile/(.*)$ profile.php?name=$1 [L]
(index.php is the home page to the site).
When I try this, it doesn't come up with a 404, it comes up with the profile page, but without styling, it can't access the javascript I have in the root directory folder and the query didn't execute properly.
I have some simpler rewrites already active on the site so the rewrite engine is definitely on, but this more complicated style doesn't seem to work. Is it even possible to do this? And if so, what am I doing wrong?

Set an index page for a specific folder in .htaccess

What I want to do should be quite simple: when the admin writes www.example.com/admin I want that he's addressed to www.example.com/admin/admin_index.php.
I wrote this rule and I checked on other posts here on Stackoverflow: it apparently seems to be correct, but it actually doesn't work.
RewriteEngine On
RewriteRule ^/admin/?$ /admin/admin_index.php [L,NC]
Has anyone any clue on why the redirect doesn't work, since it "stays" at www.example.com/admin outputting (obviously) the 403 error?
There is no need to use a rewrite rule. Just use DirectoryIndex directive in admin/.htaccess:
DirectoryIndex admin_index.php
This will load admin/admin_index.php when a request comes for http://domain.com/admin/

htaccess URL rewrite issue - permalinks

I am having some issues trying to prettify some URL's. Basically I need to make this URL http://domain.com/actualfolder/fakepath/this-is-the-article.php to display content from this page http://domain.com/actualfolder/articlemanager.php.
The articlemanager.php is setup to receive a GET url variable in the way of the "this-is-the-article" and search for it in the database. If found, it will display content specific to that result. This part works.
The part that i can't make it to work is the htaccess rule.
This is my rule but it returns 404 not found or 500 if i don't use the initial slashes.
Options +FollowSymLinks
RewriteEngine On
RewriteRule ^fakepath/([^/.]+).php$ articlemanager.php?permalink=$1 [L]
I could really use some help, so any suggestion is welcome.
EDIT: the htaccess file lies in the domain.com/actualfolder/ location

Opencart: SEO URLs not working in the second store

My default store is http://www.mydomain.com/store1
My second store is http://store2.mydomain.com
In the .htaccess file, I have RewriteBase /store1/
In the Admin - Catalog > Information, the About Us page is set to appear in both stores.
This URL works fine: http://www.mydomain.com/store1/about_us
However this URL shows Internal Server Error: http://store2.mydomain.com/about_us
Is it happening because the default store is installed within a folder(/store1/) and not in the root? Is there a way to resolve this issue?
Yes this is caused by the RewriteBase being set. Simply remove the RewriteBase /store1 line from your .htaccess file and that should fix it. Most sites will be able to guess the correct RewriteBase and so it's not necessary. If that doesn't work, you may want to try this solution

htaccess selective redirect

I am trying to redirect all sub-directory pages to main directory, except of a few pages (e.g. (somepage1.html).
RewriteEngine On
RewriteCond %{REQUEST_URI} !^/(de|ru)/somepage1.html
RewriteRule ^([a-z]{2}|zh-CN|zh-TW)/(.*)$ /$2 [R=301,L]
Everything working except de/somepage1.html is redirected to home page (/), which is not acceptable. I wont it not redirected at all.
How can I achieve it
Thanks1
Well above rules are clearly excluding de/somepage1.html URL so it is most likely some other rule that is redirecting de/somepage1.html to /. Are you using wordpress or some other CMS tool by any chance? That might have its own rules in .htaccess file, check that please.
Also it would help to check web server's access log when this redirection happens.
the code I provided is working perfectly, so if somebody looking for this kind of a solution can use it without a fought.
The reason for not working is that my website were keeping cash and therefore was not renew frequently.

Resources