Mod_Rewrite and the Paragraph Marker (PilCrow) - php

I built a website that works fine in development but not working correctly in production. I can't tell if the issue is related to the .htaccess or improperly configured vhosts. Essentially, the issue comes with the URL rewrites in my custom framework which relies on URL parameters called controller and action. Visiting a url such as domain.com/account/new would rewrite as domain.com/index.php?controller=account&action=new. Instead, when doing a dump of the $_SERVER global at the very beginning of my bootstrap (before any application logic has had a chance to mess with anything) I'm receiving this:
["QUERY_STRING"]=> string(41) "controller=index.php&action=index¶ms="
Where does that pilcrow (paragraph marker) come from? It doesn't matter what URL I try it still comes out that way.
NOTE: Other sites on the same server are able to do URL rewrites with no problem. It seems to be only this one.
I have verified mod_rewrite module is loaded and shows up in php -i / phpinfo().
Here is my .htaccess:
RewriteEngine On
RewriteBase /
RewriteRule ^([^/]+/)*favicon\.ico$ assets/img/favicon.ico [L,NC]
RewriteCond %{REQUEST_URI} ^/assets.*$
RewriteRule ^(.*)$ - [L,NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !favicon\.ico
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]+)(/)([^/]+)(/)(.*) index.php?controller=$1&action=$3&params=$5 [L]
RewriteRule ^([^/]+)(/)(.*) index.php?controller=$1&action=$3&params= [L]
RewriteRule ^([^/]+)(/) index.php?controller=$1&action=index&params= [L]
RewriteRule ^([^/]+) index.php?controller=$1&action=index&params= [L]
Dev Environment:
MacOS 10.7
Apache 2.2.22
PHP 5.4.15
Production Environment:
Linux (Kernel 2.6.32)
Apache 2.2.3
PHP 5.3.3
TL;DR; My .htaccess rules are rewriting incorrectly and including a pilcrow (paragraph marker) followed by "ms=". Is this a problem with my htaccess rules? Does this seem like a server issue? I'm tearing out my hair trying to figure this out.
EDIT #1
I just noticed that in my htaccess, something like this index.php?controller=$1&action=$3&params= contains "&para" which is the HTML entity for the pilcrow symbol which would make complete sense why it turns into that symbol followed by ms=. Now the bigger question is why would an htaccess process HTML entities?
EDIT #2
Ok, so I must be ignorant. It was displaying that because I was viewing it in the browser. When I went to "view source" it comes through as ["QUERY_STRING"]=> string(41) "controller=index.php&action=index&params=". Ok fair enough, now to figure out why it is catching the filename index.php in the $1 variable. Hmm.

I was unable to solve my issue so I rewrote everything to pass all values as a "resource" in my .htaccess like:
RewriteRule ^(.*) index.php?resource=$1
And then within the application logic I handled all of the processing. Thanks for viewing.

Related

Rewrite/hiding some URL in .htaccess

I'm trying to get right syntax for .htaccess without any result...
I've a URL structured as domain.com/app/public/pageName .
It's working fine but I would "hide" the 'app/public/' part in browsers, basically doing something like:
[real URL] domain.com/app/public/pageName -> domain.com/pageName [what users type and see in browsers]
I think in that way it should be more readable and seo-friendly.
As I understood from docs (and maybe it's wrong because it's not working...) I should tell to Apache to map/redirect all URL like domain.com/pageName to domain.com/app/public/pageName , but only internally, in order to show the minimal URL in users' browsers.
Right now I have something like:
RewriteEngine on
#RewriteBase /app/public/
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.+)$ https://localhost/app/public/index.php?url=$1 [QSA,L]
(I'm using full URL with https://... in order to get something that will be quick and easy to adapt when I upload all to my hosting, is it right?).
Problem is that RewriteRule actually change the URL, because it perform a redirect and URL rewrite it's not handle internally.
So, first of all: is it possible what I'm trying to do? If so, how can I handle the URL rewrite only internally?
Everything should be uploaded to a shared hosting, so I don't have other than .htaccess.
Anyway, I can consider to upgrade to a vps if there are not other possibilities...
Thanks!
==============
EDIT (should be more clear now)
tl;dr version:
I'm looking for a method that let users to type domain.com/pageName (and they will see that address in their browsers) and rewrite internally that URL in order to point to domain.com/app/public/pageName.
==============
More: after /app/public/ there can be an arbitrary number of elements, separated by / . All of these elements are appended at the end of the URL after index.php. At the end URL looks like:
domain/app/public/index.php?url=lot/of/elements/here
This is already working with the RewriteRule posted above, I would keep that too.
Thanks!
This is working fine for me, Hope it will work for you as well.
Check .htaccess here
RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_URI} ^/app/public
RewriteRule ^app/public/(.*)$ /$1 [L,QSA]
Just for reference, I found a solution, maybe will be usefull for someone.
Basically I moved .htaccess to the root server (instead of /app/public directory) and changed the RewriteRule as follow:
RewriteEngine on
RewriteBase /app/public/
#RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php?url=$1 [PT]
Now it's working (at least on localhost).
What do you think? Are there any side effects with this config?

Apache2 not working with routes PHP

I am developing an app with PHP 7.0 and implementing routes with MVC. My root folder ('/') is the 'public' directory. When I access the address 'localhost' I am redirected to index.php with have the routes available. But when I try another url to access another route, like 'localhost/contact' the server doesn't find the entry and give this message:
Not Found
The requested URL /contact was not found on this server.
I am pretty sure that the problem in on my server config (apache2 on linux mint 18), because my friend's PC works normal. I'm using a .htaccess file too inside the public directory:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ index.php [NC,L]
It seems to me that the server does not run index.php and tries to access the path. How could I ever force the execution of index.php to see if there is a route to the url informed?
here follows my apache2 config files.
http://pastebin.com/2mgSjWWV
http://pastebin.com/yD4RpfK8
I'm still newbee and I understand very little in server configuration. Please someone can give me a light? Thanks!
This:
RewriteRule ^.*$ - [NC,L]
It matches EVERYTHING, and since it's tagged [L], no other RewriteRules will be evaluated, so all rewriting stops here. That means a request for example.com/foo will match this rule, rewriting stops, and a literal foo file will be searched for in the file system - which doesn't exist.
And then, even if this one rule wasn't there, this next line
RewriteRule ^.*$ index.php [NC,L]
would also not work. ANY url would match it, but then strip off the relevant data, so a request for example.com/foo would be identical to a request for example.com/index.php. no query parameters would be passed in.
Your logic should be more like:
RewriteRule ^(.*)$ index.php?args=$1 [QSA,L]
which would do these sorts of translations:
example.com/foo -> example.com/index.php?args=foo
example.com/bar?baz -> example.com/index.php?args=bar&baz
After an exhaustive battery of tests, I found a solution. The htaccess file and code was fine. The problem was my server not reading the .htaccess. Editing the apache2.conf and seting 'AllowOverride All' on , finally works.
This page https://docs.bolt.cm/3.0/howto/making-sure-htaccess-works help me to solve that!

htaccess rewrite ".../pages/about.php" to ".../about"

I've searched and found a lot of questions on this site and elsewhere that are very similar, but I've tried implementing and modifying all the suggestions I've found and none of it works. I realize this is a very basic question an I am extremely frustrated because nothing I'm trying is working.
With that having been said... I am trying to organize my content pages within kurtiskronk.com/pages/... (e.g. kurtiskronk.com/pages/about.php)
What I want to do is make it so that I can simply link to kurtiskronk.com/about ... So how do I go about stripping "pages/" and ".php"? I don't have a ton of content pages, so it's not a big deal if I have to specify for each page, though something dynamic would be handy.
NOTES: I am using Rackspace Cloud hosting, and WordPress is installed in /blog. My phpinfo() can be seen at http://kurtiskronk.com/pages/phpinfo.php
This is my existing .htaccess file (in the root)
php_value register_globals "on"
Options +FollowSymLinks
RewriteEngine On
#301 redirect to domain without 'www.'
RewriteCond %{HTTP_HOST} ^www\.kurtiskronk\.com$ [NC]
RewriteRule ^(.*)$ http://kurtiskronk.com/$1 [R=301,NC]
RewriteBase /
RewriteCond %{ENV:PHP_DOCUMENT_ROOT}/pages/$1 -f
RewriteRule ^(.*)$ pages/$1 [L]
RewriteCond %{ENV:PHP_DOCUMENT_ROOT}/pages/$1.php -f
RewriteRule ^(.*)$ pages/$1.php [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^blog/ blog/index.php [L]
# PHP - MAIL
php_value mail.force_extra_parameters -kurtis#kurtiskronk.com
I tested and the rewrite works with the line below (/about as URL brings up file /pages/about.php), but then the homepage gives a 500 Internal Server Error:
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ /pages/$1.php [L]
So I'm still sort of in the same boat as before, and as a follow-up, possibly more difficult question, if you go to http://kurtiskronk.com/weddings I am using SlideShowPro (flash) w/ SSP Director (self-hosted) as the back-end for it. When it pulls up a new image, it adds the following after /weddings ... "#id=album-152&num=content-9698"
There are four sections of the portfolio
# Homepage (kurtiskronk.com) id=album-148 ($id is constant for this section)
# Weddings (/weddings) id=album-152 ($id is constant for this section)
# Portraits (/portraits) id=album-151 ($id is constant for this section)
# Commercial (/commercial) id=album-150 ($id is constant for this section)
Assuming we get kurtiskronk.com/weddings to rewrite successfully without breaking anything, how would we make the total URL something cleaner kurtiskronk.com/weddings/9698 since the $num is the only thing that will change within a given section?
Kurtis, thanks for the extra information. It's a lot easier to give a specific answer to this.
My first comment is that you need to separate out in your thinking URI space -- that is what URIs you want your users to type into their browser -- and filesystem space -- what physical files you want to map to. Some of your mappings are URI->URI and some are URI->FS
For example you want to issue a permanent redirect of www.kurtiskronk.com/* to kurtiskronk.com/*. Assuming that you only server the base and www subdomains from this tree, then this cond/rule pair should come first, so that you can assume that all other rules only refer to kurtiskronk.com.
Next, you need to review the RewiteBase documentation. .htaccess files are processed in what Apache calls a Per-Directory context and this directive tells the rewrite engine what to assume as the URI base which got to this directory and .htaccess file. From what I gather, your blog is installed in docroot/blog (in the filesystem, and that you want to get to directory by typing in http://kurtiskronk.com/blog/ but that this .htaccess file is for the root folder -- that is the base should be (this goes before the www mapping rule)
DirectorySlash On
DirectoryIndex index.php
RewriteBase /
#301 redirect to domain without 'www.'
RewriteCond %{HTTP_HOST} ^www\.kurtiskronk\.com$ [NC]
RewriteRule ^(.*)$ http://kurtiskronk.com/$1 [R=301,NC]
You can add some field dumps look for REDIRECT_* in the Server or Environment table in the phpinfo O/P to see if these are sensible. For example:
RewriteWrite ^(.*)$ - \
[E=TESTDR:%{DOCUMENT_ROOT}/pages/$1.php,E=TESTPDR:%{DOCUMENT_ROOT}/pages/$1.php]
Your next rule is that if the file exists in the subdirectory pages then use it:
RewriteCond %{DOCUMENT_ROOT}/pages/$1 -f
RewriteRule ^(.*)$ pages/$1 [NS,L]
[Note that some shared service sites don't set up DOCUMENT_ROOT properly for the rewrite engine so you may need to run a variableinfo script (<?php phpinfo(INFO_ENVIRONMENT | INFO_VARIABLES); to see if it sets up alternatives. On your site you have to use %{ENV:PHP_DOCUMENT_ROOT} instead.]
Your next rule is that if the file exists, but with the extension .php in the subdirectory pages then use it:
RewriteCond %{DOCUMENT_ROOT}/pages/$1.php -f
RewriteRule ^(.*)$ pages/$1.php [NS,L]
Now redirect any blog references to the blog subdirectory unless the URI maps to a real file (e.g. the blog stylesheets and your uploads.)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^blog/ blog/index.php [L]
A complication here is that WP may be using a poorly documented Apache feature call Path Info that is a script can act as a pseudo directory so http://kurtiskronk.com/blog/tag/downtown/ is redirected to docroot/blog/index.php/tag/downtown/ which is then executed by `docroot/blog/index.php using /tag/downtown/ as the PATH_INFO. But this is one for Wordpress experts to comment on. If this last rule doesn't work then try:
RewriteRule ^blog/(.*) blog/index.php/$1 [L]
PS. I like your site. I wish I was that young again :(
Postscript
When you say "it doesn't work", what doesn't with this .htaccess?
http://kurtiskronk.com/phpinfo,
http://kurtiskronk.com/phpinfo.php,
http://kurtiskronk.comblog/tag/downtown/
It's just that these rules work for these tests (with domain swapped) on mine. (One way is to move or copy the above variableinfo.php to the various subdirectories. If necessary temporarily rename the index.php to index.php.keep, say, and copy the variableinfo.php to the index.php file. You can now enter the various URI test patterns and see what is happening. Look for the REDIRECT_* fields in the phpinfo output, and the SCRIPT_NAME will tell you which is being executed. You can add more {E=...] flags to examine the various pattern results. (Remember that these only get assigned if the rule is a match.
Lastly note the changes above especially the additional NS flags. For some reason mod_rewrite was going directly into a subquery which was resulting in redirect: being dumped into the file pattern. I've had a look at the Apache code and this is a internal botch to flag that further redirection needs to take place (which then replaces this or backs out). However this open bug indicates that this backout can be missed in sub-queries and maybe that's what is happening here. Certainly adding the NS flas cured the problem on my test environment.
PS. Note the added explicit DirectoryIndex directive and also that whilst http://kurtiskronk.com will run the root index.php, the explicit /index.php version will run the one in pages, because that's what your rules say.
Here is a simple solution. You can use it apache conf file(s) or in .htaccess (easier to set up when you're trying).
mod_rewrite has to be enabled.
For example, use .htaccess in your DocumentRoot with:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ /pages/$1.php [L]
It will redirect /about to /pages/about.php, and any other page.
The "RewriteCond" part is to authorize access to an existing file (eg: if you had an "about" file at the root of your site, then it will be served, instead of redirecting to /pages/about.php).
Options +FollowSymLinks
RewriteEngine On
RewriteRule /([0-9]+)$ /pages/$1.php [L]
Put something like this in your .htaccess file. I guess that is what you want.
Juest a redirect from a simple url to a longer url.

Strange behavior with mod_rewrite

I am trying to perform this type of rewrite
http://sitename/foo/var1/var2 -> http://sitename/foo/index.php?/var1/var2
This is my .htaccess file(placed in the directory foo):
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?$1 [L]
In my php script I am displaying the values of $_SERVER['REDIRECT_QUERY_STRING'] and $_SERVER['REQUEST_URI']
If I request a URL like http://sitename/foo/bar the values as expected are bar and /foo/bar respectively.
This also works as expected for: http://sitename/foo/admin and http://localhost/foo/bar.
However when I try to access http://localhost/foo/admin (using localhost instead of sitename) the REQUEST_URI changes to /admin/?admin (this is how it displays in the address bar too, i.e http://localhost/foo/admin/?admin)
I searched for any .htaccess files that might be conflicting and also turned on mod_rewrite logging at level 6 but was unable to find any info.
I have no clue what might be causing it. It would be great if I could know what might be causing this, otherwise I might switch to nginx.
Thanks all for replies. This was some weird server configuration error, things seem to be fine on the new VM I installed. #Dan Grossman , thanks for your suggestion about using $_GET, some of my code is simpler than earlier.

.htaccess issues: No input file specified

Can someone help me with this? I'm feeling like I've been hitting my head against a wall for over 2 hrs now.
I've got Apache 2.2.8 + PHP 5.2.6 installed on my machine and the .htaccess with the code below works fine, no errors.
RewriteEngine on
RewriteCond $1 !^(index\.php|css|gfx|js|swf|robots\.txt|favicon\.ico)
RewriteRule ^(.*)$ /index.php/$1 [L]
The same code on my hosting provider server gives me a 404 error code and outputs only: No input file specified. index.php is there. I know they have Apache installed (cannot find version info anywhere) and they're running PHP v5.2.8.
I'm on Windows XP 64-bit, they're running some Linux with PHP in CGI/FastCGI mode. Can anyone suggest what could be the problem?
PS. if that's important that's for CodeIgniter to work with friendly URLs.
Update1:
mod_rewrite is installed and on.
What I've noticed is that if I change in RewriteRule to /index.php?$1 (question mark instead of forward slash) it goes into an infinite loop. Anyway, using question mark isn't an option as CodeIgniter (required) is not going to work this way.
Homepage also works when I request index.php directly: example.com/index.php
I'm starting to think it might be apache thinking that once the trailing slash is added it is not a file anymore but a folder. how to change such a behaviour?
Update 2:
I was wrong.
Apache handles these URLs correctly.
Requesting http://example.com/index.php/start/ (homepage) or any other valid address works.
Seems that Apache is just not forwarding the query for some reason.
Update 3:
Just to be clear what I'm trying to achieve.
I want to rewrite addresses like that:
http://www.example.com/something/ => http://www.example.com/index.php/something/
http://www.example.com/something/else/ => http://www.example.com/index.php/something/else/
I was beating my head up against this as well. I'm also installing Code Igniter.
The goocher was no RewriteBase. Here's my .htaccess:
DirectoryIndex index.php
RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond $1 !^(index\.php|robots\.txt)
RewriteRule ^(.*)$ index.php?/$1 [L]
The Problem
I encountered a similar problem just now and unfortunately none of the answers in this thread helped:
Zend Framework was giving out "No input file specified.", but:
The default RewriteBase was just fine, and adding RewriteBase / did not help
It's a shared hosting server and only FastCGI is available (no ability to switch to SuPHP)
AcceptPathInfo was on
There was no problem with URL rewriting in general on the server
So the answer came from the following site:
https://ellislab.com/forums/viewthread/55620/P15 [dead link]
(even though the host is not DreamHost).
The Solution
Apparently all you need to do is replace this line:
RewriteRule ^(.*)$ index.php/$1
With this:
RewriteRule ^(.*)$ index.php?/$1
Problem solved.
This worked for me:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]
</IfModule>
After index.php, the question mark is important!
Try if it works with a simpler RewriteCond; like one that rewrites only everything that isn't an existing file/folder/link:
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^(.*)$ /index.php/$1 [R,L]
Go Daddy Users:
login to your Go Daddy Account
click on your hosting account.
go to Settings > File Extensions Management
change .php and .php5 to run under PHP5.2X (instead of PHP5.2xFastCGI)
SOLVED!!!!
mod_rewrite is a bit too smart for its own good, because it tries to figure out what sort of redirect it should be doing. In this case it looks to mod_rewrite like you're trying to redirect to a folder, so it looks for the folder and can't find it, hence the error.
Edit: Just to be perfectly clear I think your best bet is to change your rewrite rule to:
RewriteRule ^(.*)$ /index.php?$1 [L]
unless there is a very speciic reason why you want it to be a forward slash.
Edit 2: I see that you already tried this. The reason you're getting an infinite loop is because you have index.php in your rewrite condition. If you remove that you should be free of the infinite loop.
this code will fixed this issue.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]
</IfModule>
.htaccess for Live Server :-
DirectoryIndex index.php
RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond $1 !^(index\.php|robots\.txt)
RewriteRule ^(.*)$ index.php?/$1 [L]
.htaccess for Localhost :-
RewriteEngine On
#RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule (.*) index.php/$1
It is very likely that the administrator of your host has disabled the ability to use Rewrite in .htaccess. They might not even have mod_rewrite installed.
Drop them an email and ask
Since this is a server configuration issue, perhaps you should ask at Server Fault
Edit (since you are sure that the server is configured correctly)
Have you considered tagging your RewriteCond with an end of line $?
RewriteCond $1 !^(index\.php|css|gfx|js|swf|robots\.txt|favicon\.ico)
Will (based on my limited knowledge) block any url that contains index.php, css, gfx ... at the start of a url. Because you don't have a $ at the end of the regexp, it will also block any urls that continue on from there...
I.e www.yourdomain.com/index.php/something is not redirected, same with www.yourdomain.com/js/something
Perhaps you want to add a $, which will require the url to end immediately after your regexp.
RewriteCond $1 !^(index\.php|css|gfx|js|swf|robots\.txt|favicon\.ico)$
Here is one time I caught no input file specified right on action:
This causes it:
RewriteRule ^(.*\.swf)$ redirect_php.php/?a=1 [last]
This corrected it:
RewriteRule ^(.*\.swf)$ redirect_php.php?a=1 [last]
note the / before query ?
This seems really related to AcceptPathInfo, which is about the ability to read paths after file names:
http://domain.com/file.php/tricky_path/?regular_query_stuff
Since this question seems to attract a lot of attention I'd like to propose another answer for people having encountering the same problem and are unable to solve it with the help of the existing answers. I myself was one of those people until five minutes ago.
Always, I mean always check your server logs because they might present useful information to you.
After checking my server logs (Apache2.4) I found out that open_basedir caused the trouble:
mod_fcgid: stderr: PHP Warning: Unknown: open_basedir restriction in effect. File(/data/sites/domain/public/index.php) is not within the allowed path(s): (/usr/local/lib/php:/usr/local/bin:/data/sites/domain/http-docs) in Unknown on line 0
mod_fcgid: stderr: PHP Warning: Unknown: failed to open stream: Operation not permitted in Unknown on line 0
In this case, open_basedir could not handle a symbolic link I created because it points to the outside of the open_basedir settings. Either broaden the open_basedir setting to also the new location or move the required files to the inside of any allowed directory..
You may be using Nginx, not an Apache. The error message will be the same.
echo out your sever data to be sure.
echo $_SERVER["SERVER_SOFTWARE"];
I spent hours trying all recipes from SO until I found the solution: you have to add question mark (?) after ".php", so last line of your rewrite rules will look like:
RewriteRule ^(.*)$ index.php ? /$1 [L]
There was no ? In my CodeIgniter setup from previous server, cause it usedpure Apache (no Nginx). And no recipes with port forwarding, nginx reconfiguration or php-fm reinstallation helped -- I tried them all on my VDS.
That simple method solved all in seconds.
In my case, the rewrite engine was conflicting with the doc_root directive in php.ini. The rewrite engine was treating the rewritten URL as a local file path and prefixing it with the document root, only to be prefixed again by PHP.
The solution was to rewrite to a relative URL, and add the PT flag. This tells mod_rewrite to pass the result to normal URL processing.
RewriteRule "^/(unwanted-part)/(.*)$" /$2 [PT]
In my case I am running laragon it's happening due to php.ini file, then I removed the php and install it again and it worked successfully. I think made some changes in php.ini file that's why it's displaying no input specific. After installing php.ini it fixed my issue.
update php.ini
Maybe your server has AcceptPathInfo disabled that is essential for that kind of URL to work properly. Try to enable it:
AcceptPathInfo On
Ok, try this rule:
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule !^index\.php(/|$) index.php%{REQUEST_URI} [L]

Categories