I need to remove pages full link path from the web link: http://web.example.com/web/#bwc/index.php to be http://web.example.com/
What modifications has to be done?
Try this:
<IfModule test_rewrite.c>
RewriteEngine On
RewriteRule ^(.*)$ web/$1 [L]
</IfModule>
I hope it will help..
If you use Apache, https://gist.github.com/wataruoguchi/649963c3ee18640e0105 will be the answer.
ErrorDocument 503 /maintenance.html
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_URI} !=/maintenance.html
RewriteCond %{REMOTE_ADDR} !=127.0.0.1
RewriteRule ^.*$ - [R=503,L]
</IfModule>
You can simply rewrite maintain.html to index.html
Related
I've created a Syfmony 5.2 project and on my local I've used symfony serve -d. So, when I've put the project live, I need an .htaccess file. Well, it looks like below:
DirectoryIndex index.php
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_URI}::$0 ^(/.+)/(.*)::\2$
RewriteRule .* - [E=BASE:%1]
RewriteCond %{HTTP:Authorization} .+
RewriteRule ^ - [E=HTTP_AUTHORIZATION:%0]
RewriteCond %{ENV:REDIRECT_STATUS} =""
RewriteRule ^index\.php(?:/(.*)|$) %{ENV:BASE}/$1 [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ %{ENV:BASE}/index.php [L]
</IfModule>
<IfModule !mod_rewrite.c>
<IfModule mod_alias.c>
RedirectMatch 307 ^/$ /index.php/
</IfModule>
</IfModule>
The result?
The page isn’t redirecting properly
Please, can someone tell me what I've missed?
please have a look here:
https://symfony.com/doc/current/setup/web_server_configuration.html
I am not very familiar with Apache, I usually use NGINX but on first look, it looks like you need to define a document root to /var/www/project/public.
I hope you can move forward with this information.
I need to make a target, when the user access, https://www.dominio.com.br/portal/anything be directed to https://www.domain.com.br/blog
Is it possible to do this with .htaccess?
Here is the code I have:
<ifModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_METHOD} OPTIONS
RewriteRule .* / [R=200,L]
RewriteRule ^portal/([a-z0-9\-]+)/$ ^blog/ [QSA]
</ifModule>
Note: Inside the portal folder, I already have an index.php pointing to blog. This .htaccess would go inside this folder.
<ifModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^portal/(.*) blog/$1 [L,QSA]
</ifModule>
I have deployed a Symfony application to my production server. Now I need to remove /web from the domain name, and I have searched for different solutions for this. For example I tried this, but it only resulted in a 500 error. I have read the answers of many similar questions, but I can´t find a solution that works. Could anyone give me a clue?
This is my htaccess-file:
DirectoryIndex app.php
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTP_HOST} ^mydomain.se$ [NC,OR]
RewriteCond %{HTTP_HOST} ^www.mydomain.se$
RewriteCond %{REQUEST_URI} !folder/
RewriteRule (.*) /web/$1 [L]
</IfModule>
<IfModule !mod_rewrite.c>
<IfModule mod_alias.c>
RedirectMatch 302 ^/$ /app.php/
</IfModule>
This is what works for me
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ web/$1 [QSA,L]
</IfModule>
I'm having a problem with rewrite rules in my cake 2.2.0 app.
Mod_rewrite seems to be working as going here:
myapp.com/listings works
But links generated by cake construct this type of URL, which also work but are not being rewritten:
myapp.com/app/webroot/index.php/listings
I've tried a lot of posted options but nothing seems to work?
My apache config is set up as follows:
<Directory />
Options FollowSymLinks
AllowOverride All
</Directory>
All .htaccess files are standard from the cake install?
Webroot .htacess:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php [QSA,L]
</IfModule>
App .htaccess:
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^$ webroot/ [L]
RewriteRule (.*) webroot/$1 [L]
</IfModule>
root .htaccess:
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^$ app/webroot/ [L]
RewriteRule (.*) app/webroot/$1 [L]
</IfModule>
Should I be looking at anything else?
This is something you should be able to fix in cakephp when you generate your links. The htaccess files that you have won't change the links in your page content.
If for whatever reason, you can't do this in cakephp, then you can add this to your Webroot htaccess, right below the RewriteEngine On line:
RewriteCond %{THE_REQUEST} \ /app/webroot/index.php/([^\ ]+)
RewriteRule ^ /%1 [L,R=301]
and that will redirect the browser to the shorter URL.
In case any one else looks at this, my problem was that this line in /app/Config/core.php was uncommented:
Configure::write('App.baseUrl', env('SCRIPT_NAME'));
Commenting it out removed the abs URL /app/webroot/index.php/ from my URLs.
Happy coding.
Please can somebody take a look at my .htaccess code to help identify what's wrong.
I am trying to amend all example.php, example.html and example.htm URL's to index.php?filename=example.html
Options +FollowSymLinks
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^(index\.php) - [L]
RewriteRule ^([^/\.]+).(php|html|htm)$ index.php?filename=$1.html&%{QUERY_STRING} [L]
</IfModule>
When I enter a URL like example.html I'm taken to the default 404 and not index.php
Try:
Options +FollowSymLinks
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?filename=$1 [L,QSA]
</IfModule>
I'm not using the apache .hatacces for a while,
But try this one:
RewriteEngine On
RewriteCond %{REQUEST_URI} !^/index\.php$
RewriteCond %{REQUEST_URI} !^.*/(css|img|js)($|/.*$) [NC]
RewriteRule ^(.*)$ /index.php?filename=$1&%{QUERY_STRING} [L]
Basically what you need is to be sure that the URL didn't have already index.php. You accomplish it with RewriteCond.
After you redirect all to index.php passing the filename as a parameter.
You can add more exception to the RewriteCond like on this example, all content with /css, /js, /img will not pass to this rule.
You can check this thread: Using .htaccess to reroute all requests through index.php EXCEPT a certain set of requests also