I do not know why, but this simple Rule will not work.
<IfModule mod_rewrite.c>
Options -MultiViews
RewriteEngine On
RewriteBase /
RewriteRule ^rubbellos\.png/$ rubbellos/rubbelbild_png.php [NC,L]
RewriteRule ^rubbellos\.css/$ rubbellos/rubbellos_css.php [NC,L]
</IfModule>
If I copy the xyz/rubbellos/rubbelbild_png.php to browser it is OK.
My approach is to bring the request of rubbellos.png to the .php-file. But I get a file not found.
Thx for any hint in advance.
You have 2 errors:
use a RewriteBase since you're talking about a subdirectory /xyz/ in your question.
disable MultiViews option to avoid unexpected behaviour with rubbellos (virtual file and existing directory).
You can replace your current code by this one in your htaccess (which has to be in /xyz/ folder)
Options -MultiViews
RewriteEngine On
RewriteBase /xyz/
RewriteRule ^rubbellos\.png$ rubbellos/rubbelbild_png.php [L]
RewriteRule ^rubbellos\.css$ rubbellos/rubbellos_css.php [L]
Note: don't forget to replace xyz by your real subdirectory's name
Related
In my application we have write root directory name(gaming) statically in coding on some pages which are showing as link in GUI. Now whenever I am trying to click on such URLs its redirect me on url1 which is not accessible for me. So is there any possible ways in which I can access url1 without remove such statically name throughout application?
URL 1 :
http://abc:8089/gaming/app/test/unique_testing.php
URL 2 :
http://abc:8089/app/test/unique_testing.php
I have tried some htaccess overwrite rules but it's not working for me.
My current htaccess looks like below :
Options +FollowSymLinks -MultiViews
RewriteEngine On
RewriteBase /
RewriteRule ^gaming(/.*|)$ /$1 [L,NC]
Structure :
/var/www/html/gaming/app/test/unique_testing.php
/var/www/html/gaming/.htaccess
Inside root /gaming./.htaccess you can use this rule:
Options +FollowSymLinks -MultiViews
RewriteEngine On
RewriteRule ^app(?:/.*)?$ /$0 [L,NC]
Please use this rules in your .htaccess
Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /
RewriteRule ^app/(.*)$ /$1 [L,NC,R]
I want to modify URL with a check.
If there exists experiment as second folder, then do this
{site}.com/dashboard/experiment/closed/.../
to
{site}.com/experiment/closed/.../
If no experiment found in path, then don't do anything. For eg
{site}.com/dashboard/ex-view/closed/.../
How do I achive this using htaccess. I'm using Laravel 5.1.
This is what I tried but it doesn't meet the second condition.
Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /
RewriteRule ^experiment/(.*)$ /$1 [L,NC,R]
You can try this rule in the .htaccess in the root. The should only affect URL with experiment as the second folder.
Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /
RewriteRule ^.+/experiment/(.*)$ /experiment/$1 [L,NC,R]
Hi I want To Ask How Can I convert
http://abc.tk/comments.php?post_referrel_id=16
to
http://abc.tk/comments.php?post_referrel_id/16
using .htaccess mod_write
RewriteBase /
Options +FollowSymlinks -MultiViews
RewriteEngine On
RewriteRule ^comments\.php\?post_referrel_id/([^/]*)$ /comments.php?post_referrel_id=$1 [L,QSA]
RewriteEngine on
RewriteRule comments.php?(.*)/(.*)/$ /comments.php?$1=$2 [L]
A URL rewrite wouldn't matter in this instance, as your still using query strings. It would make more since to eliminate the Query string all together with something like:
http://abc.tk/comments.php/post_referrel_id/16
Nevertheless, this can be achieved using .htaccess
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule comments.php?post_referral_id/(.*)$ /comments.php?post_referral_id=$1 [L]
</IfModule>
Which will still use the same code, but be recognized by a different URL.
Check this out.
RewriteEngine On
RewriteBase /
RewriteRule ^comments\.php\?post_referal_id/([^/]*)$ /comments.php?post_referrel_id=$1 [L,QSA]
.htaccess looks like this:
Options +FollowSymLinks +ExecCGI
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_URI} !(\.png|\.jpg|\.gif|\.jpeg|\.bmp|\.ico)$
RewriteRule ^(.*)$ entryPoint.php [QSA]
</IfModule>
this enforces all request running though entryPoint.php. This processes all files, redirects, etc. Images are free to go, there can be direct references to them. But what about CSS, JS files? I cant add exceptions - because it would reveal the directory structure. All I want is:
script src="ds.jss" while they can be at "js/" or "module/x/js/". Same with CSS.
I understand I can do it with entryPoint.php: file_get_contents and outputs. It does work, but its too slow. First we tried it with pictures too.
How to enable a "direct access"?
Options +FollowSymLinks +ExecCGI
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ entryPoint.php [QSA]
</IfModule>
Try adding these rewrite conditions...
If you don't want to do that within the php file, you need to add a rule:
Options +FollowSymLinks +ExecCGI
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^ds\.jss$ module/x/ds.jss [L]
RewriteCond %{REQUEST_URI} !(\.png|\.jpg|\.gif|\.jpeg|\.bmp|\.ico)$
RewriteRule ^(.*)$ entryPoint.php [QSA]
</IfModule>
The important part is the L flag which stands for Last Docs. It will prevent the other rules to run.
If you want to resolve the filename dynamically but you don't want to use PHP to provide the actual file but your apache server, you can still use PHP to resolve the filename by creating a dynamic rewrite map Docs, search for External Rewriting Program.
Im using a Framework which has this .htaccess file:
Options +FollowSymLinks +ExecCGI
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_URI} !(\.png|\.jpg|\.gif|\.jpeg|\.bmp|\.ico)$
RewriteRule ^(.*)$ entryPoint.php [QSA]
</IfModule>
thats very good, because entryPoint.php runs everytime. But I have a PhpBB forum, placed in SITEROOT/forum directory. It would be the best that in this /forum directory to .htaccess be ignored. How to set a rule to be ignored in a directory?
I'm a bit rusty with my rewrite rules but,
RewriteCond $1 !^/forum
Should work.