Mod_rewrite - Changing Paths In The Php File?
I am using mod_rewrite to create "pretty" urls but some of my files contain paths such as this:
<img src="images/blah.jpg"> Meaning if the user visits a page where the file does not physically exist then it won't work.
I want to know if it is possible to pick this up and rewrite the path. I.e.:
change: <img src="images/blah.jpg">
to: <img src="../images/blah.jpg">
or
<img src="../../images/blah.jpg">
As I don't want to create physical files with relative urls for every trunk of my url. For example:
www.mydomain.com/directory/directory/directory/
Would need 3 different files in three different directories to display properly.
View Complete Thread with Replies
Sponsored Links:
Related Forum Messages:
Php-cgi Isn't Work With Mod_rewrite
I have been using apache and php-cgi and it works well together but when I tried to use mod_rewrite it stopped working and I got "Internal Server Error" result. Apache error log showed "FastCGI: incomplete headers (0 bytes) received from server" I think that mod_rewrite rules are ok because when I refer to some HTML file then it all works. Apache 2.2.14 and php 5.2.11
View Replies!
View Related
Mod_rewrite Strip Off Php Extension
I am trying to figure out how to use mod_rewrite to make my php url's friendly. I have read a few articles but none seem to do what I want. Here is what I want: /login.php -> /login /home.php -> /home /users/update_profile.php -> /users/update_profile /users/update_profile.php?id=343242 -> /users/update_profile/343242 Basically just strip off the .php extension, so it seems like php files are actually folders.
View Replies!
View Related
PHP-cgi Breaks My Mod_rewrite
I had the sysadmin install SuPHP - so that my upload script would work properly, however now my mod_rewrite is broken. You can view the problem here: [url] It is supposed to show the item with id 29, as you can see. However it shows the gallery index (As if /gallery/ was typed in without the view-29) The .htaccess file: Code: #.htaccess RewriteEngine On #This will force trailing slashes RewriteCond %{SCRIPT_FILENAME} -f [OR] RewriteCond %{SCRIPT_FILENAME} -d RewriteRule .* - [L] #RewriteCond %{REQUEST_URI} !^*(css|png|jpe?g|gif) RewriteRule ^(.+)/(.+)/?$ $1.php?args=$2 [QSA,L] RewriteRule ^(.+)$ $1.php [QSA,L,NC] My very framework relies on the .htaccess working this way... I can turn it off, however I would really rather not - so if you have any idea how I can fix this, please do tell. And on a related note, is it possible to run PHP under a user and not use cgi_php?
View Replies!
View Related
Changing File Permission
i've set all folders,sub folder and files under this folder to be 777 since it is a folder for my users to upload attachments~ however this is the problem. users all failed to upload because the permission of the new folder created by apache for the users to store their attachment are set to 755, which i wanted them to be 777. (those 777 folders were from old server.) if u take a look at the pic attached , you know what i meant. does anyone have any idea of how i can change the permission for this whole foder to be 777 even with folder created by apache? i tried chmod -r 777 attachment, but it says operation not permitted @@
View Replies!
View Related
Changing Multiple File Permission
in my server there is an issue where a lot of users simply chmod their directories to 0777 and its not easy for me to modified them back or ask them to change it back. so anyone knows how can i search server via ssh to grep folder with permission 0777 and then automatically chmod these folders to 0755 ? i think its possible to complete the above task with 1 command but not sure how.
View Replies!
View Related
Changing Settings For Php.ini On IIS
I have IIS on my computer and I want to start using a php driven forum (SMF) on my web site. Before I upload the files I need to check the following settings are on: the engine directive must be On. the magic_quotes_sybase directive must be set to Off. the session.save_path directive must be set to a valid directory, or empty. the file_uploads directive must be On. the upload_tmp_dir must be set to a valid directory, or empty. I cant find anywhere within IIS where these directions maybe found. Can anyone point me in the right direction?
View Replies!
View Related
Links Files In Linux (file.txt For File.php)
Today I found some cstomer on the servers make a link for named it file.txt and link it to other customer php file. so that customer have the ability to show the other custoer file content when visiting the url because it is a text wile originally it is a php file. the php file was a config file, so now he know the database password , and because he is in the same server he can use that databse. the question , how to avoide this prolem in the future? notes , the SuExec is rnning and the open_basedir protection is enabled, but the problem still exists.
View Replies!
View Related
Changing Register_globals From .htaccess Will Cause 500 Error When Php Run As CGI
Today I have a customer want to swich the register_globals on on his account ,,, i'm running PHPSuExec and running php as cgi not as Apache module , and as you know using php as cgi will cause internal error 500 if some one add php_flag register_globals on to .htaccess file. what is the soluation to switch register_globals on for his account only without using the .htaccess file. put in mind the php files that need the register_globals to be on is encrypted with zend , so we does not have access to it for modification. have any one have the solution?
View Replies!
View Related
Strange PHP File On My VPS. (oxb.php)
I found a strange PHP file in a strange folder on a VPS I am using to host a few sites. I've looked through the logs but can't figure out how it got there and I've look at the code and can't make any sense of it. Can somebody take a look at the code and tell me what they think of it: .....
View Replies!
View Related
Mapping User Paths
I'm not even sure I'm asking this in the right place, but here we go. We are working on creating some load tests for our system and we need to figure out how a "normal" user navigates our system. Is there software out there that will show use how a user navigates our system via reading the apache logs? Will awstats do the trick?
View Replies!
View Related
Home Web Server Set Up, Relative Paths Not Working
I've had a web server set up for a while at home to do some testing. I can view the site locally using my IP but all relative paths of CSS or images on the html page (eg /something/title.gif) don't show up. Bizarrely, if I go to[url], they appear! Anyone know what the issue may be? The "DocumentRoot" value in Apache conf is pointing to the correct folder.
View Replies!
View Related
PHP File Upload
I think I messed php config and I can't upload anything with php now Dir is chmoded on 777 and File_Uploads = On in php.ini I'm running lsphp5 with suhosin, when I try to import db via phpmyadmin I get error: Uploading is not allowed and when I try to upload some file via php script I can't
View Replies!
View Related
Php File Corruption
I have a Linux VPS with Liquidweb which is working fine except for one problem: On one domain I have a shopping cart (a highly modded CubeCart). A number of the files are encrypted php files (part of the extensive mods). For several weeks all will work fine, then out of the blue, the cart will stop working because a number of the encrypted files have become corrupt. The result is either a totally blank page or a 'checksum error'. Uploading the files from a local backup fixes things for another few days or weeks. I have no idea why this is happening, or what triggers it, so if anyone can point me in the right direction to find out what is behind the problem, I would greatly appreciate it. The server uses PHP 5.2.x
View Replies!
View Related
Cron: How To Run Php File
My server with cPanel, I'd like run file http://domain.com/file.php at 0h00 everyday, I have set the Cron Job in cPanel : Code: 0 0 * * * /usr/bin/ehpwget http://domain.com/file.php but The cron is not working well Code: /bin/sh: /usr/bin/ehpwget: No such file or directory Can any one please let me know how to run a php file with cron. (as user or root)
View Replies!
View Related
[php] <defunct> - What File Generating That ?
On my server, i have one user ho create load on my server. user 29508 22.0 0.0 0 0 ? Z 15:18 0:00 [php] <defunct> That user has more site added with addons from cpanel. How can I found witch site is generating that high load ? Also some time, I have php index.php ( and that don't help me very much ) The server run php as cgi module.
View Replies!
View Related
PHP Permissions (file Owner)
I have setup an ftp user which can upload files to /home/ftp/upload and obviously it assigns the ftp user as the owner when it uploads. Now, I want PHP to be able to rename those files, but getting a permission denied, presumably because apache aint the owner or doesnt have permission to do that, so how do I grant it the right permission(s)?
View Replies!
View Related
PHP File Change String
I currently have this code in my Image Upload script which changes the file name into sets of numbers and letters Quote: $new_file_name = "uploads/" . md5($_FILES['selector']['name'] . time()) . "." . $extension; How can i make it so its smaller than an md5, about 6 or 7 numbers and letters.
View Replies!
View Related
Prevent PHP Files Used For File Uploading
It appears that some people like to take advantage of those files for online web applications such as Wordpress which have php files with permissions set to 777. They use those as a means of creating an upload file. The upload files that they create then have access to the whole server somehow... Is there anyway of preventing this from happening?
View Replies!
View Related
Chmod Choices With Php Writing To A File
My account has been hacked with every index.php page defaced. I've cleaned up and my shared wehost is pointing at me saying there shouldn't be any 777 permissions for any files in there. I used 777 to allow php to add records in a txt file and in an xml file. Is there a better / more secure chmod code I can use? Those are the only two instances where I need php to write to a file and those files shouldn't be served to anyone, I do not want anyone to be able to access them. How can I secure them while letting php write in them?
View Replies!
View Related
Php.ini And .htaccess File Permissions
I'm on a shared FreeBSD server, running Apache with Drupal, and vBulletin. I had to create a local php.ini file in my public_html folder for Drupal, and another in my forum folder for vBulletin. Now my question is, what should I set the permissions of these files to? Also, what should I set .htaccess permissions to as well? I'd like to keep them invisible to the public. But, I don't want any problems with Drupal, or vBulletin ether. I'm used to using Linux and I know how permissions work on a desktop. I just don't know what they do when used on a server. I'm guessing 640, but I'd like to make sure before I change anything.
View Replies!
View Related
Strip Whitespace From Each Line Of PHP File
I have a load of PHP files that need trimming down, so for example Code: <html> <?php $loads_of_stuff = 1231231; ?> </html> change to Code: <html> <?php $loads_of_stuff = 1231231; ?> </html> There are 000's of lines, so some awk command or something similiar would be great to execute on each file.
View Replies!
View Related
How To Prevent People Upload Unwanted .php File
I have a 777 cmod folder open. It needed to be writable so that legitimate users can upload their picture. However, i do not want people to upload .php or .php.pjepg etc to the server. There are times that they do not use the form in my site to upload the php file. How can they do that? via perl command? And how to prevent such thing from happending?
View Replies!
View Related
How To Secure Your Php.ini File Safe Mode ; Disable_functions ; Etc
what are the most important issues for secure php.ini file like when you turn your SAFE_MODE ON or OFF? or please who every read this topic to post his important disable_functions in php.ini ... and if some functions disable to post it ... let's make this subject for the most important issues for secure your php.ini from script-kids as we can ... here i have some important question's for anyone has or controlling a server ; vps .... #0x01 ; what the most important disable_functions for the php.ini? #0x02 ; is the safe_mode should be enabled? or disable? and this depend on what exacly? #0x03 ; what the functions or any trick to control the nobody ( attacker on the server or shell ) FROOZ .... didn't move ? or make any command in the server ... #0x04 ; i saw in some secure server ( as they say ) they changed the Server : discribe to them name[s] like Server : SECURE BY US .COM OR SECURE SERVER .. uname -a : Linux secure.secure.com 2.6.9-023stab040.1 #1 Mon Jan 15 23:24:32 MSK 2007 i686 athlon i386 GNU/Linux sysctl : linux 2.6.9-023stab040.1 Server : SECURE BY US ! < [THIS WHAT I MEAN HOW COULD WE CHANGE IT IN PHP.ini ?] id : uid=99(nobody) gid=99(nobody) groups=99(nobody) <[how can we cannot make this nobody to have the host id ! everyhost in the server should have his own name and php.ini ?] pwd : /home/host/public_html/ #0x05 ; how can we hide the uname -a on the shell [ the attacker upload it to our customer site !] #0x06 ; how can we hide the sysctl to view to anyone like [ attacker ] ... #0x07 ; how can we rewrite on he Server Type the display for our secure message?Server : SECURE BY US ! #0x08 ; how can we give evey site and customer his php.ini file in his public_html? and how can we give him [ JUST HIS PERMISSION TO HIS SITES FOLDER AND NOT OTHER PATHS AND PERMISSION!] these question every one had a server ; vps , need to know and secure his box from other ... and anyone would like to publish any new [secure or not] idea please let us know what you would like to say ....
View Replies!
View Related
Simpleish PHP/flat Files - Create File, Edit, Save
Display some text in a web browser from a file called text.txt text.txt will have many lines and some of them I do not want users to be able to modify and overwrite. config_item_1=user can edit config_item_2=user should see but not edit (could be on any line) config_item_3=user can edit config_item_4=user can edit The user has made their changes in the web browser and clicks submit. I then need this info to be saved as the text.txt file however some checking needs to be done first. Anything matching config_item_2 should be removed. This could be on any line. Anything not matching should be permitted and added.
View Replies!
View Related
How Detect Paths Of ImageMagick And Test ImageMagick?
I buy some webhosts from various hosting providers. I installed vBulletin on one host and ImageMagick do not work. Hosting provider said ImageMagick is installed. Also I checked phpinfo and sow it is really installed. But ImageMagick still do not work! So, I need anything to detect real ImageMagick paths, status, components. and also I need anything to test ImageMagick if it works or not.
View Replies!
View Related
Proc List Only Shows "/usr/bin/php" - No More File Names
We use cpanel on our centos servers and we've updated our servers recently using easyapache to the latest php4 and mod_suphp and I've noticed that in top (running "top c" in shell) all php processes by any user are simply displayed as "/usr/bin/php" Before this update the processes also showed the file name eg. "/usr/bin/php lamescript.php" which allowed to easily find troublesome scripts ... but now there's no way of knowing what the script in question is that's eating up 100% of the cpu .. or is there?
View Replies!
View Related
Mod_rewrite
Its October and I have a Server at home with me running NO CONTROL PANEL... I have been using it for 5 years now... But my problem is my mod_rewrite is not working... I have tried fixing it... But I can't find it in the httpd.conf file where I heard it was at... They said it came by default by Apache.. I'm running Apache2.2.4, Fedora Core 7), PHP 5, MySQL 5.... I don't see the mod_rewrite on there....
View Replies!
View Related
Mod_rewrite RewriteMap
I have a list of categories that i want to rewrite the URL to display the names instead. I'm using this: RewriteMap catlist txt:C:/web/apache2/htdocs/catnames.txt RewriteRule ^/cats/(.*)$ /categories.php?catid=${catlist:$1|0} catnames.txt consists of CategoryName 6 AnotherCatName 8 OnemoreCatName 9 ..... and so on. This works fine on my local windows PC since i'm using httpd.conf to set this up. When i use this on my server under .htaccess, the error log says "RewriteMap" not allowed here. I it only to find out that i cant use RewriteMap under .htaccess... Is there any other alternative to achieve this without listing all the category names with corresponding rewriteurl statements in my .htaccess file?
View Replies!
View Related
Installing Mod_rewrite?
I have installed a Apache server version 1.3.33 on windows XP and would like to enable mod_rewrite so i can rewrite my ugly url´s. How do I install this great feature in Apache so i can test it locally? Do i just remove # from #LoadModule rewrite_module modules/mod_rewrite.so #AddModule mod_rewrite.c
View Replies!
View Related
Mod_rewrite Tracking
I've lots of: [warn] RewriteCond: NoCase option for non-regex pattern '-f' is not supported and will be ignored. [warn] RewriteCond: NoCase option for non-regex pattern '-d' is not supported and will be ignored. Any ideas how to track them?
View Replies!
View Related
Apache And Mod_rewrite
So I've setup a server heres the spec provided by Webmin Operating systemUbuntu Linux 8.10 Webmin version1.470 Time on systemSun Mar 29 18:56:12 2009 Kernel and CPULinux 2.6.27-11-server on i686 System uptime5 days, 19 hours, 42 minutes I'm struggling with mod_rewrite their seems to be no such thing... Its not mentioned in the apache2.conf or httpd.conf, httpd.conf was blank previously but I added in certain things to get php working but I cannot get mod_rewrite working, which brings the question forward what else am i missing? I started out with the aim of blocking the ability of viewing directories. Quote: Loaded Modules core mod_log_config mod_logio prefork http_core mod_so mod_alias mod_auth_basic mod_authn_file mod_authz_default mod_authz_groupfile mod_authz_host mod_authz_user mod_autoindex mod_cgi mod_deflate mod_dir mod_env mod_mime mod_negotiation mod_php5 mod_setenvif mod_status mod_vhost_alias So how can I go about getting mod_rewrite setup and/or what ever else I'm missing that I might find essential later on once I have everything setup?
View Replies!
View Related
IIS And Mod_rewrite
I've just moved a few webistes from Linux to Windows and I'm using IIS to run them. Does anybody know of any free alternatives to ISAPI_REWRITE so I can use mod_rewrite per account?
View Replies!
View Related
Lighttpd Mod_rewrite
I am struggling to get this .htaccess file to work with lighttpd, i am not a coder so its very hard for me to fix it, hopefully if someone knows how can tell me how to write rewrite code that will get it working. {quote} 1. Comment the 2 lines below if the server returns 500 errors! Options -Indexes Options +FollowSymLinks #Uncomment following lines if you want to use image caching! #<IfModule mod_expires.c> 1. ExpiresActive On 2. ExpiresDefault A1209600 3. ExpiresByType text/html A1 #</IfModule> 1. Uncomment following lines if Apache doesnt support MultiViews! <IfModule mod_rewrite.c> RewriteEngine On 1. Uncomment the 2 lines below if you are using www.domain.com # as the baseurl for the site and users access your site # via domain.com (THIS IS REQUIRED FOR JQUERY TO WORK) #RewriteCond %{HTTP_HOST} ^domain.com [NC] #RewriteRule ^(.*)$ http://www.domain.com/$1 [L,R=301] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule .* loader.php [L,QSA] </IfModule> 1. Edit below lines and set to 2. ErrorDocument CODE /RELATIVE/error.php 3. If the script is installed in the default document 4. root then relative is null. #ErrorDocument 401 /error.php #ErrorDocument 403 /error.php #ErrorDocument 404 /error.php {/quote} looks like its calling the rule from loader.php file, now how can i convert this to lighttpd language,
View Replies!
View Related
Mod_Rewrite (Enable It)
I have a VPS and I need to enable mod_rewrite. Here is my PHP Info: [url] I read a tutorial but I just don't get it. I would appreciate if you could help me out. I need it for my Wordpress blog.
View Replies!
View Related
.htaccess Mod_rewrite
I'm trying to redirect everything except the subdomains from an old domain to a new domain. The following appears to work so far: Options +FollowSymLinks RewriteEngine on RewriteCond %{HTTP_HOST} !^sub1.olddomain.com$ [NC] RewriteCond %{HTTP_HOST} !^sub2.olddomain.com$ [NC] RewriteCond %{HTTP_HOST} !^sub3.olddomain.com$ [NC] RewriteCond %{HTTP_HOST} !^sub4.olddomain.com$ [NC] RewriteRule ^(.*)$ http://newdomain.com/$1 [R=301,L] But the subdomains also seem to be loading rather slow. Am I doing anything wrong here? Is there any way to optimise or simplify this (I have around 11 subdomains on the old domain)?
View Replies!
View Related
Mod_Rewrite Subdomain
I am attempting to redirect any subdomain as follows: subdomain(dot)domain(dot)com to domain(dot)com/index.php?user=subdomain I am having some issues doing this though. None of the samples online seem to work. Do I need a wildcard subdomain? Do I need to do anything to the dedicated linux server I am on? I have other sites on the same server all using mod_rewrite successfully. Here is what I have so far: RewriteEngine On RewriteCond %{HTTP_HOST} !^w{3}. [NC] RewriteCond %{HTTP_HOST} ^([^.]+).domain.com$ [NC] RewriteRule ^.*$ /index.php?user=%1 [L] Is there anything I am missing to get this thing working?
View Replies!
View Related
Mod_rewrite / Lighttpd
how can I run a equivalent on lighttpd like this: # BEGIN WordPress <IfModule mod_rewrite.c> RewriteEngine On RewriteBase /blog/ RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /blog/index.php [L] </IfModule> # END WordPress
View Replies!
View Related
Netfirms Finally Has Mod_rewrite!
Hey guys... Not sure if this was posted yet, couldn't find anything on a first-glance search. Netfirms has finally added mod_rewrite capabilities as well as better .htacces support! Now I'm completely happy. I was considering switching over to Dreamhost due to the fact that I've started running blog software and messy URLs = crap. Now there's no need. That was pretty much the only thing that was holding me back from a full endorsement, so if anyone's looking for a good cheap hosting plan, here's some of the stuff that I'm really happy about for $5 a month: - quick, personal customer service (I think there's only 1 or 2 guys, and they always seem to be able to answer my questions on the spot) - mod_rewrite - .htaccess - reliable clean FTP (no _vti files or other annoying folders like so many companies these days) - good online knowledgebase - nice online site stats viewer - a bunch of other great stuff that I probably have forgotten about or don't use - only $5! Just thought I'd share in case the news hadn't spread yet. Not sure when they added it, but I noticed the "NEW" sticker today.
View Replies!
View Related
Does Mod_rewrite Consume RAM?
does mod-rewrite consume ram? actually found in new vb discussion of seo friendly urls and mod rewrite was an option for most friendly url, so wanted to know if constant usage of mod-rewrite adds additional load to the server or not? forum which I and my friends use are pretty big more than 6k in a forum and other above 25k, with 250k posts in 1 forum and 600k posts in the other, so just give me an idea on wat can happen due to constant overwritten?
View Replies!
View Related
Mod_rewrite And Boolean Logic?
If I want to apply a rule if (Condition A and (Condition B OR Condition C)) is true, will the following work? RewriteCond Condition A RewriteCond Condition B [OR] RewriteCond Condition C Or will the following? RewriteCond Condition B [OR] RewriteCond Condition C RewriteCond Condition A Or neither? Or both?
View Replies!
View Related
Mod_rewrite - Restart Required
i have a bunch of rewrite rules that work fine on my dev server but when i upload to production server they dont work. is a restart of apache required? im on a dedicated box so this shouldnt be a problem, but how do people on shared accounts do this then?
View Replies!
View Related
Mod_rewrite, Vhosts, And Errorlog
I tried searching the forums a bit and the Apache manual, but I was unable to find much related to my specific problem. We have a system such that each user has a 'www' folder in their home directory so that example.com/~user will point to that folder. The user information, however, is not on the www server and instead we use a network file system to access the files in the home folder. This all works fine and dandy with mod_rewrite. However, we want to allow each user to have access to the error logs, etc. for their own site. The best way to do this seems to simply store it in their home directory. The problem is that how do you split these files apart. While it would be possible to have a separate process do it, the best way seems to just have each user be their own vhost. mod_vhost_alias seems to be applicable in this situation. However, mod_vhost_alias relies on either the Host: field or the ip to split queries into their respective vhosts. As said before, our system uses the directory. So the question is, is there a way to either use mod_rewrite to tell mod_vhost_alias what the vhost's name is. Or, is there a way to split the logs another way.
View Replies!
View Related
Infinite Loop From Mod_rewrite
I am having trouble figuring this out. I am receving this error in my error log: Code: [error] [client XX.xxx.XXX.x] Request exceeded the limit of 10 internal redirects due to probable configuration error. Use 'LimitInternalRecursion' to increase the limit if necessary. Use 'LogLevel debug' to get a backtrace. Now Earlier I had that ip keep accessing my server for an odd reason. So I used mod_rewrite to block its requests. Code: RewriteRule file /index.php [R=301,NC] RewriteRule file2 /index.php [R=301,NC] RewriteRule file3 /index.php [R=301,NC] So I am convinced Errors I am getting with these are from bots that are not accepting the redirects?
View Replies!
View Related
|