PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Tuesday, February 8, 2022

[FIXED] start URL rewriting in current folder

 February 08, 2022     .htaccess, apache, lamp, php     No comments   

Issue

I have a website in a subdirectory of my domain (example.com/folder)

In this folder I have a .htaccess with this code

RewriteEngine On 
RewriteRule . index.php

When I do a request to this http://www.example.com/folder/example/request my $_SERVER['REQUEST_URI'] is set to /folder/example/request.

How can I force apache to not put the /folder/ into the request_uri-variable.


Solution

Since you're dealing with $_SERVER['REQUEST_URI'] you're already in PHP. Why not just strip /folder off if it's there?

Don't modify $_SERVER['REQUEST_URI'] directly by the way, copy it, modify it, and pass it along to whatever function needs it.

PHP is much better at manipulating strings than Apache.



Answered By - Halcyon
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home
View mobile version

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing