Categories: php, html, apache, .htaccess

How to forward the HTTP_REFERER to a page from htaccess?

1 answer

When someone hits my site root folder (www.myDomain.com) and the Index.php page gets it after that, how can I forward HTTP_REFERER to the Index.php page so I can record it?

I have this but No Joy.

RewriteEngine On RewriteCond %{HTTP_REFERER} !^mydomain.com [NC] RewriteRule ^/?index.php?%{HTTP_REFERER}$ mydomain.com/ [L,R] 

Thanks

All answers to this question, which has the identifier 61063966

The best answer:

Make sure apache mod_rewrite is enabled. Then redirect with:

<IfModule mod_rewrite.c>     # Make sure url's can be rewritten.     RewriteEngine on      # Redirect requests that are not files or directories to index.php.     RewriteCond %{REQUEST_FILENAME} !-f     RewriteCond %{REQUEST_FILENAME} !-d     RewriteRule ^ index.php [L] </IfModule> 

This is how most CMS's do it. this does mean if they write the direct path to a file they will see that file. So you will want to precede this with something like:

# Prevent direct access to these file types. <FilesMatch "\.(sql|md|sh|scss|rb|conf|rc|tpl(\.php)?|lib(\.php)?|wig(\.php)?|pg(\.php)?|reg(\.php)?|db(\.php)?)$">   Require all denied </FilesMatch> 

This means that they can not access the file extensions listed above. You can replace the last few with just rc|php but I allow access to .php files not proceeded with .lib so I can do scripts protected by browser authentication for debugging and silver bullet database repairs.

You must also have something like this in your apache config that allows the .htaccess to be read in your sites directory.

<Directory "C:/Sites">     AllowOverride All </Directory> 

Last questions

how do i remove the switch on my home screen?
how to edit the JS date and time to update atuomatically?
How to utilize data stored in a multidimensional array
Powermockito not mocking URL constructor in URI.toURL() method
Android Bluetooth LE Scanner only scans when phone's Location is turned on in some devices
docker wordpress container can't connect to mysql container
How can I declare a number in java that is more than 64-bits? [duplicate]
Optaplanner solutionClass entityCollectionProperty should never return null error when simple JSON object passed to controller
Anylogic, get the time a pedestrain is in a queue
How do I fix this syntax issue with my .flex file?
Optimizing query in PHP
How to find the highest number of a column and print two columns of that row in R?
Ideas on “Error: Type com.google.firebase.iid.zzav is referenced as an interface from com.google.firebase.messaging.zzd”?
JCIFS SmbFile.exists() and SmbFile.isDirectory() return false when it exists and I can listFiles()
PHP total order
Laravel booking system design
neural net - undefined column selected
How to indicate y axis does not start from 0 in ggplot?
Fragments in backStack
Spinner how to change the data