I want to hide the admin folder. The structure of my website is:
Fron-End:
https://example.com/
Back-End:
https://example.com/admin/
So when you open the site and right-click to see the source code on the site, the images it pulls from the admin folder are displayed like https://example.com/admin/public/images/image.jpg.
How can I hide the admin folder without disturbing anything that pulls from the admin panel or without disturbing the functionality of the site itself? So the result will be in the end https://example.com/public/images/image.jpg.
I resolved my issue with this answer:
RewriteEngine on
RewriteRule ^admin/(.+)$ /$1 [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule (.+) /admin/$1 [END]
Related
My htaccess code is not working correctly. Hoping to get some help. It's working perfectly unless I click a link within on of my subfolder pages. Here is my code:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^/]+)/$ $1.html
RewriteRule ^([^/]+)/([^/]+)/$ /$1/$2.html
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !(\.[a-zA-Z0-9]{1,5}|/)$
RewriteRule (.*)$ /$1/ [R=301,L]
I removed the .html and added a trailing slash.
When I click on a link when I am within one of my subfolder pages, it generates a weird URL.
Example: When I am at the URL: http://domainname.com/product/2-jars-500mg-hemp-extract-pain-relief-cream/
and I click on the link: href = '/product/3-jars-500mg-full-spectrum-hemp-extract-pain-relief-cream'
It rewrites the link as /product/2-jars-500mg-hemp-extract-pain-relief-cream/3-jars-500mg-full-spectrum-hemp-extract-pain-relief-cream which causes a 404 error.
I currently online have one htaccess file in the public_html folder
This site is hosted through GoDaddy on an apache server.
I tried adding the same htaccess file into the product folder, but that messes up the rewrite.
Rules looks fine, check in source code in browser your url... maybe it's relative and without slash at the beginning or end of uri ( example product/3-jars-500mg... not /product/3-jars-500mg.../ )
You need href = '/product/3-jars-500mg-full-spectrum-hemp-extract-pain-relief-cream/'
that the rule RewriteRule ^([^/]+)/([^/]+)/$ /$1/$2.html would be true.
I want write an URL like this
http://my-site.it/Existingfolder/FolderNotExist
But I would that url will remain the same (with FolderNotExist) but continue to show this page
http://my-site.it/Existingfolder/
How can i do using .httaccess ?
Actually my Website in Joomla go to Error404 with
http://my-site.it/Existingfolder/FolderNotExist
You can try this rule before default Joomla front controller rule:
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.+?)/[^/]+/?$ $1/ [L]
Situation:
I'm moving a website from a production environment to a test environment.
The test environment url is similar to http://192.168.1.100/~username/
There are thousands of files which use the following within the html
<img src='/images/image.jpg' />
Since the request is going to root http://192.168.1.100/ the files are 404.
Rather than finding and replacing all of html I'd assume that there is an easy way to fix it with mod_rewrite via .htaccess.
I've tried using the following
RewriteCond %{REQUEST_URI} !^/~username/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /~username/$1
But did not work as expected.
Thanks in advance.
UPDATE
The development environment resides within cpanel/whm. So when the username is removed from the requested url, it now belongs to the root users. So, my question now: How do I update the .htaccess file for the root user to mod_rewrite back to the ~username?
If you remove
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
it appears to work as expected, because any request to the right url will not be rewritten.
you might want to add [L] as a flag to signify it's the last rewrite rule, like so:
RewriteCond %{REQUEST_URI} !^/~username/
RewriteRule ^(.*)$ /~username/$1 [L]
I run TYPO3 with a normal site and a subdomain in the same TYPO3 installation. On the normal site, automatically a mobile device is detected and then rerouted to the subdomain.
In my subdomain the visitor is redirected to the correct page in the TYPO3 tree, using following .htaccess file.
Options +FollowSymlinks
RewriteEngine On
RewriteCond %{http_host} ^m.mysite.com [NC]
RewriteRule ^(.*)$ http://m.mysite.com/index.php?id=74 [L]
What happens is that the visitor ends up in an endless loop where he is sent to the TYPO3 site and then to the subdomain and back again.
To get this working, I also need to change the working directory to www.mysite.com (I also have another provider where I can make these changes using a cpanel, and that site runs perfectly). I have been looking everywhere and have tried almost anything, but I simply do not have enough knowledge to change the working directory.
So what code should I use to change the working directory?
Use RewriteCond to not follow this rule for index.php.
Options +FollowSymlinks
RewriteEngine On
RewriteCond %{http_host} ^m.mysite.com [NC]
# Failing the index.php check, the usual test is to look for any
# existing file
# EDIT: Changed URI to start with / - should work per comments
RewriteCond %{REQUEST_URI} !^/index.php
#RewriteCond %{REQUEST_FILENAME} !-f
#RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ http://m.mysite.com/index.php?id=74 [L]
I'm a drupal newbie...
I completed my first drupal site. then client wanted to run their old CRM under new drupal site, they uploaded CRM folder into drupal folder, and when I try to address the CRM admin, as below, it redirects drupal 404 page (which is search page).
www.blablabla.com/crm/admin
Error message from drupal is below:
The page you requested does not exist. For your convenience, a search
was performed using the query 500
shtml.
is there any way that I can make drupal to ignore any folder under its folder? something via .htaccess, or I don't know :/
Appreciate helps so much! thanks a lot!
I would suggest just linking to the old cms from inside drupal.And keep the folders of the old cms outside of the drupal folders. Your old cms also probably doesn't reference the links correctly (its expecting http://oldcmslink and inside of drupal it would be http://drupal?q=something).
Drupal use these lines in the .htaccess file.
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !=/favicon.ico
RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]
To use a sub-directory below, you will need to either add a RewriteRule before this with the [L] attribute or add your subdirectory to the RewriteCond list here, such as:
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !^/crm/ # Ignore Drupal Redirects for our CRM.
RewriteCond %{REQUEST_URI} !=/favicon.ico
RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]
You'd have to make a mod_rewrite rule in your .htaccess file. Drupal directs (almost) all its requests to index.php which then sends requests to Drupal's menu router. So your CMS is never going to work unless you create a rewrite rule.
But I would take controlfreak123's advice if you can and move your old CMS site to another address. You're going to have to maintain your own version of Drupal's htaccess file and deal with this work around every time you upgrade. There is also a small chance you might have name collisions later on if you add new modules etc.