How to rewrite URL PrestaShop to hide folder? - url-rewriting

I would like to hide my folder where PrestaShop is installed.
To access my shop, I must write http://domain.com/prestashop.
But I want access to my shop like this: http://domain.com.
How can I do this?

If you don't have access to your server configuration.
Add this .htaccess to your / directory.
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_URI} !^/Prestashop/.*$
RewriteRule ^(.*)$ /Prestashop/$1 [L]
</IfModule>
Don't forget to change your shop_url in SEO / URL.

You must point your domain name to a specific subfolder.
If you point domain.com on prestashop subfolder then you should change it in your back office:
Preferences -> SEO & URLs
After the change you should disable Friendly URL and then enable it again - Enabling Friendly URL generates .htaccess

Related

CodeIgniter: keep index.php in url and hide the rest

greatings...
Question :
How to keep index.php in url and hide everything else so my url look like (www.base_url.com/index.php) for every page?
Details :
i've searched but i only got how to remove index.php, i think im the only one who want to keep it...lol
im using codeigniter 3 to working on web based app human resource managemen soo i dont need SEO url since the app only accessed by internal employees. i like to make the url clean, only show base_url and the index.php for every page. please show me how to config codeigniter like i need...thank you
Use .htaccess like this:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>
This will look more cleaner than with index.php. The URL will be like this www.your_baseurl.com/users
and edit your config.php file to use URI like this:
$config['index_page'] = '';
$config['uri_protocol'] = 'REQUEST_URI';
You can use your route like this:
$route['users'] = 'home/users';

I want to block assets folder path in Codeigniter

Am new in Codeigniter i want to block assets folder in my website. I mean website users(website viewer) enter http://www.example.com/assets it move to 404 page.
Please help me...!
Thanks in advance
If your assets folder is there to serve things like CSS, JavaScript and image files (like would be intended), and is an actual directory, then you can either do this by adding a .htaccess file to the directory (assuming it's running under Apache) which will take all requests which are not for explicit file paths and route them to the website controller/action for a 404 (or other page you use for this).
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ http://yourdomain.com/path/to/404 [QSA,L]
</IfModule>
Alternatively, you can add an index.php file which redirects the browser to the location for a 404 page, or displays a 404 type page as a response.
header("Location: http://yourdomain.com/path/to/404");

How to eliminate a sub-directory level from all URLs in Website

I have a website and I just setup an os shopping cart (ie., Magento)
I installed the cart in a sub-directory off the document root as /magento/ per the installation guidelines.
So my web site cart's URL is http://mydomain.com/magento/
I have no public pages off the document root and I actually want my cart to be my home page -- in other words, I want http://mydomain.com/magento/ to resolve as http://mydomain.com/
Is it possible? Can I use mod-rewrite to make it happen? If so, can you suggest what the mod-rewrite directives would look like?
Or is it simply a permanent redirect like:
redirect 301 /magento http://mydomain.com/
Thanks.
You can use:
RewriteEngine on
RewriteCond %{REQUEST_URI} !^/magento
RewriteRule ^(.*)$ /magento/$1
In this way, it should replace everything with /magento in front of it. So, you can have your links to point on your root.
I've edited and tested it, it works.
Now that I've better read your question, it seems you want to redirect only the home page, and not the whole site:
RewriteEngine on
RewriteRule ^$ /magento/

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/.

301 Redirect from subdomain to URL

I'm trying to set up a 301 redirect from a subdomain to a facebook page. I'm using this below and have uploaded it to the root folder on the server. I've also tried to upload this to the subfolder (example.com/blog), but to no avail...
RewriteEngine on
RewriteCond %{HTTP_HOST} ^blog.example.co.uk
RewriteRule ^(.*)$ http://www.facebook.com/example/$1 [R=301,L]
#Deny access to htaccess
Order Allow,Deny
Deny from all
Does anyone have any ideas why this isn't working?
Thanks in advance,
Ash
NOTE:
I've investigated this a little further and forgot to mention that the subdomain is set up on an old version of Drupal. This causes the site to fail when we set up any subdomain.
We can still navigate to the folder that the subdomain uses and the redirect works fine there.
So, the issue seems to be with drupal and subdomains, not the redirect.
Thanks,
Ash
What kind of error are you getting?
This bit of code would deny access to everything, not just .htaccess like it states in the comments...
#Deny access to htaccess
Order Allow,Deny
Deny from all

Resources