madewithlove / htaccess.madewithlove.com Goto Github PK
View Code? Open in Web Editor NEWIssues with our htaccess tester
Issues with our htaccess tester
Request URL: http://194.12.111.2
Htaccess:
RewriteCond %{HTTP_HOST} ^194.12.111.2$ [NC]
RewriteRule ^ https://www.some-site.com [R=301,L]
Output url: http://194.12.111.2
Should be: https://www.some-site.com
This rule kills your tool:
RewriteRule ^details/([0-9]+)/([^\/]+)/?$ /tour_details.php?com=$1 [QSA]Try with URL: http://www.xyz.com/xyzcharters/details/48984/super-test-charter
Your tool converts the URL to: http://www.xyz.com
but is not matching the rule.
It seems that as soon as this phrase is in any of the rules: ([^\/]+)
your tool fails completely.
It would be nice if there was a way to quickly indicate if the given URL is a file, a directory or neither.
I have seen a couple of suggestions here for an in depth approach that lets you define a whole directory structures and while this has merit I think it could become cumbersome for quick tests.
I would therefore like to propose that you simply add three radio buttons below the URL input to let users quickly specify how the given URL should be treated.
Good evening!
First of all: thanks for your cool tool!
Maybe I'm getting something wrong at the moment.
According to the current Apache Docs the rule RewriteRule "^/foo$" "/bar" should redirect a request from http://example.com/foo to /usr/local/apache2/htdocs/bar (it's the example from https://httpd.apache.org/docs/current/rewrite/intro.html#rewriterule).
The tool always tells me that the rule didn't met... So what's going wrong here?
Kind regards! + Thank you!
Yorick
(Please excuse my weak English – I'm a student from Germany...)
Htaccess tester would benefit from a field for the folder where the htaccess file resides - it is not always the top folder
Coming from this tweet: https://twitter.com/mws4b/status/560355367205765120
URL: http://domain.de/test/page/2
RewriteRule ^(.*)/page/([0-9]*)$ /$1/?lcp_page0=$2#lcp_instance_0 [PT]
does not work, it does not parse the string after ?, escaping will not solve it
The rule works without any problems in other htaccess testers and they also give me the full query string back as result including the get parameters and the hash string
output url: http://domain.de/test/
should be http://domain.de/test/page/2
debugging info:
RewriteRule ^(.*)/page/([0-9]*)$ /$1/?lcp_page0=$2#lcp_instance_0 [PT]
For example: http://domain.com/?foo=4&sunamy=4
RewriteRule ^ - [E=MY_QUERY_STRING:%{QUERY_STRING}]
RewriteRule ^ - [E=MY_QUERY_STRING:%1%2]
RewriteCond %{ENV:MY_QUERY_STRING} ^(.+?&|)foo.*?(&.*|)$ [NC]
RewriteRule ^ - [E=MY_QUERY_STRING:%1%2]
RewriteCond %{ENV:MY_QUERY_STRING} ^(.+?&|)sunamy=.*?(&.*|)$ [NC]
RewriteRule ^ - [E=MY_QUERY_STRING:%1%2]
We are using a "skip" syntax in out htaccess:
RewriteCond %{QUERY_STRING} !^item_id=4
RewriteRule .? - [S=6]
RewriteRule ^lernen/(.).php$ http://www.linguashop.com/hörbuch-$1? [R=301,L]
RewriteRule ^aprender-agora/(.).php$ http://www.linguashop.com/frases/$1? [R=301,L]
RewriteRule ^apprendre/(.).php$ http://www.linguashop.com/$1-facile? [R=301,L]
RewriteRule ^aprender/(.).php$ http://www.linguashop.com/frases-$1? [R=301,L]
RewriteRule ^imparare/(.).php$ http://www.linguashop.com/traduzioni-$1? [R=301,L]
RewriteRule ^learn/(.).php$ http://www.linguashop.com/$1-download? [R=301,L]This rule was met, the new url is /-ww.linguashop.com/lernen/polnisch.php
for the rule "RewriteRule .? - [S=6]" don't really seem appropriate.
htaccess http://madewithlove.be
Uses the .htaccess file in the folder you are in and applies to rules.
I think there might be an error displayed in the debugging info:
When I test some htaccess rules with the following lines:
Test-Url:
htaccess-Rules:
RewriteCond %{HTTP_HOST} ^sub.domain.info$
RewriteRule (.*) http://www.anotherdomain.com/$1 [R=301,L]
the debugging info displayed is:
The new url is http://sub.domain.info/
Test are stopped, a redirect will be made with status code 301.
Should not this redirect to http://www.anotherdomain.com ?
(sorry in case I should be wrong, but my webserver does indeed redirect to www.anotherdomain.com tested with these values)
I’m suggesting an improvement:
When we use the – to tell the server to leave the url intact, this tool seems to break.
Eg: RewriteRule ^index.php$ – [L]
When a condition was met or not everything is marked in red.
This is a little bit confusing and i suggest that the conditions which were met are marked in green.
Maybe I am do not getting how this tool works, but it seems to not match the regex in any case.
Example:
RewriteEngine on
RewriteRule ^/$ /e/www/ [R]
Input:
http://test/
This rule was not met.
This tool is brilliant, but could definitely be more comprehensive. Status codes are fairly important for SEO-based redirects; it would be nice if you detected flags like “G” ( for 410 Gone ) and displayed the relevant status code alongside the redirect URL. In the case of a 410, the URL is irrelevant as the server returns a “410 Gone” status for the source URL.
Otherwise, this tool has proved invaluable in validating that the .htaccess rules behave as requested.
I'm not sure if you want this, but your php errors are showing. I can send you a screenshot if you want or post one here.
The following example does not follow through to the second rewrite rule
RewriteEngine On
RewriteBase /
# Drupal node to wordpress url mapping
RewriteCond %{QUERY_STRING} ^q=content\/(.*)$
RewriteRule . /drupal/%1? [PT]
RewriteRule drupal/example-article /2016/09/12/example-article/ [R=permanent,L]
I can confirm that this does work in a live environment.
Cheers,
Ty
Looks like as of yesterday the share feature no longer works.
You can generate the links fine but visiting them no longer loads the test.
To reproduce:
write a test
generate share link and copy it
visit share link in new window / browser
Tested this on mac & windows on a combination of safari, firefox and chrome.
I just wonder if there is something wrong, You see when I put my code in a get a double output in the result file.
The data I put in are as follow
RewriteCond %{REQUEST_URI} (/_Test/)a.mp4
RewriteRule . $1/_Test/b.mp4 [P,L]And the mystery output is
http://test.com/_Test/a.mp4/_Test/b.mp4
Is it something wrong or is it just me doing something wrong.
To enable request filename support it could be an idea to have an additional textbox where the user can paste their output from tree https://packages.debian.org/search?keywords=tree.
You then get this branch structure after running tree foldername
which could be parsed
│ │ ├── json2.min.js
│ │ ├── masonry.min.js
│ │ ├── mce-view.js
│ │ ├── mce-view.min.js
│ │ ├── media-audiovideo.js
│ │ ├── media-audiovideo.min.js
│ │ ├── media-editor.js
│ │ ├── media-editor.min.js
│ │ ├── mediaelement
│ │ │ ├── background.png
│ │ │ ├── bigplay.png
│ │ │ ├── bigplay.svg
│ │ │ ├── controls.png
│ │ │ ├── controls.svg
│ │ │ ├── flashmediaelement.swf
│ │ │ ├── froogaloop.min.js
│ │ │ ├── jumpforward.png
│ │ │ ├── loading.gif
│ │ │ ├── mediaelement-and-player.min.js
│ │ │ ├── mediaelementplayer.min.css
│ │ │ ├── silverlightmediaelement.xap
│ │ │ ├── skipback.png
│ │ │ ├── wp-mediaelement.css
│ │ │ ├── wp-mediaelement.js
│ │ │ ├── wp-mediaelement.min.css
│ │ │ ├── wp-mediaelement.min.js
│ │ │ ├── wp-playlist.js
│ │ │ └── wp-playlist.min.js
When I type this url
http://visitjakob.dk/dk/Silkeborg
the .httaccess following here works well
But it seems to ignore [NC] when I type
http://visitjakob.dk/DK/SilkeborgOptions +FollowSymLinks
RewriteEngine on
RewriteRule (dk)/(.*)$ index.php?country=$1&city=$2 [NC]
Example taken from Apache Documentation on RewriteRule Flags.
Request url
http://example.com/pages/123?one=two
htaccess
RewriteRule pages/(.+) page.php?page=$1 [QSA]
Expectation
http://example.com/page.php?page=123&one=two
Tool output
http://example.com/page.php?page=123
It would be pretty easy to set up a few "input blocks" in a form for stuff like ip addresses, etc (any server-specific information) just like how you have the http referrer set up. It would at least give you a base to start from.
On Acquia Cloud we use SSL termination on the LB layer, which adds a X-Forwarded-Proto, so an SSL enforcing rewrite rule would look like this [1]:
RewriteCond %{HTTPS} off
RewriteCond %{HTTP:X-Forwarded-Proto} !https
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
Regardless of the protocol i use in the testing url, the RewriteCond for this header will never be met, so the above sample will always fail with the "This condition was not met." message.
I suspect this is because non-existing headers always trigger a fail, but for my use-case it would be really useful if it was supported.
[1] - https://docs.acquia.com/articles/redirecting-traffic-between-http-and-https-acquia-cloud
RewriteRule ^test$ /destination/?a=b [R=301,NE,NC,L]
The ?a=b is not included.
.htaccess
rules generated by some generators around the web generate output like this:
RewriteRule ^foo\-bar\-baz$ /new [L,R=301]
This works as expected on Apache/2.4.6, where /foo-bar-baz
gets redirected to /new
. However, http://htaccess.mwl.be/ doesn't match the URL /foo-bar-baz
. Instead, it expects the literal URL /foo\-bar\-baz
(including the backslashes!).
This is probably due to how Apache handles escaping URLs, it just strips all the \
characters from the URL somewhere in the process. As far as I'm aware, we can do just that after escaping the necessary characters in this tool.
It's a bit of an edge-case, but multiple generators have generated this output, so it'd only make sense for this checker to detect these cases.
Hi,
I put that with a question mark because really, I'm not sure.
I tried this:
RewriteCond %{HTTP_HOST} ([^.]+).domain.io [NC]
RewriteRule (.*) %1 [L]
against "bibi.domain.io/qweqwe.php"
Result is "bibi.domain.io/bibibibi"
Why is the %1 group duplicated?
On another note, %0 should return something apparently (http://httpd.apache.org/docs/current/mod/mod_rewrite.html#rewritecond) but I could not make it work.
Thanks for the help :)
Title says all.
#Options +FollowSymLinks
RewriteEngine On
RewriteCond %{HTTPS} !on
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
The output role should be with https, but it shows without it.
In debugging info, it gives following output
The new url is http://www.domain.com/
Test are stopped, a redirect will be made with status code 301
the output url is without https also
Thanks for this useful tool. But it's not working for me in the case of a partial match. If I put
RewriteRule page1 page2
It shows that http://example.com/page1.htm will be changed to http://example.com/page2.htm.
This is not what happens on my real server. The replacement string completely replaces the original. It does not do in-string substitution. So the real server gets http://example.com/page2 without the .htm extension.
Here is an example that will give an empty button line with a strange evaluation.
RewriteEngine on RewriteRule ^$ structure.php?p=main [L] RewriteRule ^saloon$ structure.php?p=saloon [L] RewriteRule ^rules$ structure.php?p=rules [L] RewriteCond %{REQUEST_URI} !=^/structure.php?p=error$ RewriteRule ^.*$ /structure.php?p=error [R]
http://localhost/salerferfoonThere is an empy line that gives "This rule was met, the new url is http://localhost/structure.php?p=error\"
Emailed by Fede on June 18, 2014 at 3:21 am CET
I have a wish, Could you make your tool like jsfiddle - means temporary saveable, with a link to share and discuss the result.
RewriteCond %{HTTPS} !=on
The result is always
This condition was met.
thank you very much for this usefull tool
Consider:
RewriteBase /foo/
RewriteRule ^(.*)bar$ $1index.php [L]
In the tester, the above example correctly inserts the RewriteBase into the relative path if necessary.
http://test.com/bar > http://test.com/foo/index.php
http://test.com/foo/bar > http://test.com/foo/index.php
However:
RewriteBase /foo/
RewriteCond %{HTTP_HOST} !^www\.(.*)$ [NC]
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [L,R=301]
In this case, the tester shows:
http://test.com > http://www.test.com/foo//
This is incorrect, since Apache doesn't apply RewriteBase when rewriting or redirecting to an absolute path.
See this tweet: https://twitter.com/SeanGinnaw/status/559765579603906560
The following code redirects primarydomain.com, secondarydomain.com and www.secondarydomain.com to www.primarydomain.com, but when you type primarydomain.com in the request url field the rule is marked as not met. This is not correct.
RewriteCond %{HTTP_HOST} ^primarydomain.com [NC,OR]
RewriteCond %{HTTP_HOST} ^secondarydomain.com [NC,OR]
RewriteCond %{HTTP_HOST} ^www.secondarydomain.com [NC]
RewriteRule ^(.*)$ http://www.primarydomain.com/$1 [R=301,nc,L]
It seems like you only can have one OR between each rule.
HI,
I would like to use your interpreter in conjunction with https://github.com/dugwood/clickheat
So I could see what pages are accessed by user/server.
Thank you,
Daniel
Right now every line in the file results in a line of output.
Even the line
#
Results is the line 'Can't match #
An .htaccess file containing a line like this does not seem to be supported:
RewriteRule ^(.*)$ index.php?route=$1 [NC,L,QSA]
A URL like http://myserver.com/myroute?myvar=myvalue should be redirected to http://myserver.com/index.php?route=myroute&myvar=myvalue. The test tool gives http://myserver.com/index.php?route=myroute, thus forgetting the variable myvar and its value.
When there is a redirect loop error it is not shown, either show it in URL(eg. http://mydomain.com/shop/shop/shop...) or in debug info.
Seems to have some trouble with %{HTTP_HOST} in RewriteCond. The following code should drop the "www" from the URL but in doing so it duplicates the %{REQUEST_URI} in the output URL. I'm guessing its because the "(.+)" in the CondPattern is including the %{REQUEST_URI} but since CondPattern should only apply to the TestString of the RewriteCond - in this case %{HTTP_HOST} - the %{REQUEST_URI} should not be put in to the variable %1 of the RewriteRule, which I believe your script is doing.
RewriteCond %{HTTP_HOST} ^www.(.+) [NC]
RewriteRule ^ http://%1%{REQUEST_URI} [R=301,L] #remove www from URL
A suggestion for the following:
RewriteCond {%REQUEST_FILENAME} !-f
RewriteCond {%REQUEST_FILENAME} !-dYou can create two text boxes (since this is for testing). One for existing directories > (you can allow them to input directory paths). The other is for existing files. If an > existing file is in a non-existing directory make it warn the user.
Then you have something to check against the two conditions.
It would be pretty easy to set up a few "input blocks" in a form for stuff like ip addresses, etc (any server-specific information) just like how you have the http referrer set up. It would at least give you a base to start from.
Add this banner onto the htacces page
https://github.com/madewithlove/projects-banner
RewriteCond %{HTTP_HOST} ^www.one.com$ [OR]
RewriteCond %{HTTP_HOST} ^www.two.com$ [OR]
RewriteCond %{HTTP_HOST} ^www.three.com$
RewriteRule ^(.*)$ http://www.wrong.com/$1 [R=301,L]
In my test the rule is always executed irrespective of what the url is.
I would expect that for http://www.one.com the rewrite would happen and for http://www.four.com it wouldn't but it always does.
Did you think about using a real apache to evaluate the rules and parsing it's log output?
Or at least using the original mod_rewrite code ?
I tried to share a test and the return link contains 'http' so when i tried to access this link he simply redirects me to a empty page.
Modifying the shared link to 'https' worked for me.
Hi there -
Don't think too many people will run into this, but just so you know there's a hard crash when you run a test on an htaccess file that's all commented out. For example:
#RewriteCond %{HTTP_HOST} !=www.domain.com [NC] #RewriteRule ^(.*)$ http://www.domain.com/$1 [R=301,L]
Thanks for the great tool! The support of RedirectMatch
would make it even more awesome!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.