apache rewrite file names
-
miss_d_bus
- Forum Members

- Posts: 121
- Joined: Sun May 01, 2005 4:27 pm
apache rewrite file names
I wonder if anyone has any suggestions. I want to move my static pages over to CMS. This would be practical as theres over 150 of them but the file names have a .php file extension.
So that the links to the pages still remain, I would like to use the CMS system to preserve the existing file names because the site is well established in google.
I got it working with the Apache rewrite file name feature so it would make the file names .html but can it be done to write them to .php?
I tried it and it didnt work so i wonder if it is technically possible because the system is written in PHP and i assume the file name being rewritten is index.php?=page
Any suggestions of how to do this will be greatly recieved.
Thanks,
Catherine
So that the links to the pages still remain, I would like to use the CMS system to preserve the existing file names because the site is well established in google.
I got it working with the Apache rewrite file name feature so it would make the file names .html but can it be done to write them to .php?
I tried it and it didnt work so i wonder if it is technically possible because the system is written in PHP and i assume the file name being rewritten is index.php?=page
Any suggestions of how to do this will be greatly recieved.
Thanks,
Catherine
-
amygdela
Re: apache rewrite file names
what's the mod_rewrite code you've used? Can you post your .htacces file contents?
-
miss_d_bus
- Forum Members

- Posts: 121
- Joined: Sun May 01, 2005 4:27 pm
Re: apache rewrite file names
i got the information from the documentation here:
http://www.cmsmadesimple.org/moduleinte ... eturnid=63
To enable clean URLs:
Copy /doc/htaccess.txt to /.htaccess
Edit config.php and change
$config["assume_mod_rewrite"] = false;
to:
$config["assume_mod_rewrite"] = true;
Add the line:
RewriteCond % !-f [NC]
just before RewriteRule (in /.htaccess)
This will make Apache check to see if the file already exists. You can now change the ".shtml" to ".htm" or anything else. Just edit RewriteRule, and edit config.php by changing:
$config['page_extension'] = '.shtml';
to:
$config['page_extension'] = '.htm';
Just to clarify if you find that the rewrite rule doesn't work as expected, try
RewriteRule ^(.+)\.shtml$ index.php?page=$1
instead of the provided code, which is:
RewriteRule ^(.+)\.shtml$ index.php?$1
I hope that helps. Thanks.
http://www.cmsmadesimple.org/moduleinte ... eturnid=63
To enable clean URLs:
Copy /doc/htaccess.txt to /.htaccess
Edit config.php and change
$config["assume_mod_rewrite"] = false;
to:
$config["assume_mod_rewrite"] = true;
Add the line:
RewriteCond % !-f [NC]
just before RewriteRule (in /.htaccess)
This will make Apache check to see if the file already exists. You can now change the ".shtml" to ".htm" or anything else. Just edit RewriteRule, and edit config.php by changing:
$config['page_extension'] = '.shtml';
to:
$config['page_extension'] = '.htm';
Just to clarify if you find that the rewrite rule doesn't work as expected, try
RewriteRule ^(.+)\.shtml$ index.php?page=$1
instead of the provided code, which is:
RewriteRule ^(.+)\.shtml$ index.php?$1
I hope that helps. Thanks.
-
djkirstyjay
- Forum Members

- Posts: 206
- Joined: Tue Oct 25, 2005 4:50 pm
Re: apache rewrite file names
You could also try sticking an Iframe in your content and putting the php page in that...
That's what I'd do, but I'm a php novice!
That's what I'd do, but I'm a php novice!
-
miss_d_bus
- Forum Members

- Posts: 121
- Joined: Sun May 01, 2005 4:27 pm
Re: apache rewrite file names
what do you mean?
I need to keep the same file names of the files already on the website. I am not sure how that would solve it? I have over 150 files ending with .php
I didnt think iframes worked in older browsers very well and so thats something I would prefer to avoid. I dont think i would use an iframe. Wouldnt a server side include do the trick?
Thanks for the suggestion
I need to keep the same file names of the files already on the website. I am not sure how that would solve it? I have over 150 files ending with .php
I didnt think iframes worked in older browsers very well and so thats something I would prefer to avoid. I dont think i would use an iframe. Wouldnt a server side include do the trick?
Thanks for the suggestion
-
djkirstyjay
- Forum Members

- Posts: 206
- Joined: Tue Oct 25, 2005 4:50 pm
Re: apache rewrite file names
I dunno about server side includes... I'm a php novice, as mentioned
... it's something that my banner ad software does, which runs on php, so I just thought it might help.
It uses an Iframe to put the banners on the page which I included in the template. It works...
what i meant was, if this is a BASIC!!! template :
{title}
If you are seeing this, your browser doesn't support Iframe. etc... etc...
Where content.php is the idex of your php files and would navigate normally within the Iframe...
So you would put your php pages in the content and they would appear in the iframe on the template.
Forgive me if I'm talking out of my backside, just trying to help...
Kirsty
PS: I'm not sure it does work in older browsers, but I'm not too bothered about my ads not showing in older browsers, as it will only show an 'impression' if it's actually displayed, so it works ok for me.
Actually... thinking more about this, I may be talking out of my backside...
hmmmm... I'll have another think.
It uses an Iframe to put the banners on the page which I included in the template. It works...
what i meant was, if this is a BASIC!!! template :
{title}
If you are seeing this, your browser doesn't support Iframe. etc... etc...
Where content.php is the idex of your php files and would navigate normally within the Iframe...
So you would put your php pages in the content and they would appear in the iframe on the template.
Forgive me if I'm talking out of my backside, just trying to help...
Kirsty
PS: I'm not sure it does work in older browsers, but I'm not too bothered about my ads not showing in older browsers, as it will only show an 'impression' if it's actually displayed, so it works ok for me.
Actually... thinking more about this, I may be talking out of my backside...
Last edited by djkirstyjay on Wed Oct 26, 2005 12:06 pm, edited 1 time in total.
-
amygdela
Re: apache rewrite file names
What do frames have to do with mod_rewrite?
=======
Edit this line in your code miss_d_bus:
$config['page_extension'] = '.htm';
to:
to:
$config['page_extension'] = '.php';
Done!
It's that easy...!
=======
Edit this line in your code miss_d_bus:
$config['page_extension'] = '.htm';
to:
to:
$config['page_extension'] = '.php';
Done!
-
miss_d_bus
- Forum Members

- Posts: 121
- Joined: Sun May 01, 2005 4:27 pm
Re: apache rewrite file names
iframe doesnt have anything to do with mod_rewrite.
The iframe solution doesnt help as it doesnt effect the file names so it wont help the problem but thanks for your help.
I thought i had changed the .htaccess settings etc to the right things as it now works so the file names end in .html
i wondered if there was a specific problem with having a .php ending because the orginal file being rewritten was .php too.
I'll have another look at it.
The iframe solution doesnt help as it doesnt effect the file names so it wont help the problem but thanks for your help.
I thought i had changed the .htaccess settings etc to the right things as it now works so the file names end in .html
i wondered if there was a specific problem with having a .php ending because the orginal file being rewritten was .php too.
I'll have another look at it.
-
amygdela
Re: apache rewrite file names
Or I don't understand you, or you don't understand me.
My given code rewrites all extensions to .php . Ain't that what you wanted?
My given code rewrites all extensions to .php . Ain't that what you wanted?
-
miss_d_bus
- Forum Members

- Posts: 121
- Joined: Sun May 01, 2005 4:27 pm
Re: apache rewrite file names
thanks yes that did work. I think i did something wrong the first time round which was why I was a bit confused but it all works and so everything sorted now.
Thanks a lot!!
Thanks a lot!!
-
miss_d_bus
- Forum Members

- Posts: 121
- Joined: Sun May 01, 2005 4:27 pm
Re: apache rewrite file names
hmmm its not as simple as i first thought.
Now the pages have all been changed to .php BUT
I cant access the admin area any more. I get this error:
Warning: Smarty error: unable to read resource: "db:admin/index" in /usr/local/psa/home/vhosts/kentradiohire.co.uk/httpdocs/TEST/lib/smarty/Smarty.class.php on line 1088
Any ideas?
Now the pages have all been changed to .php BUT
I cant access the admin area any more. I get this error:
Warning: Smarty error: unable to read resource: "db:admin/index" in /usr/local/psa/home/vhosts/kentradiohire.co.uk/httpdocs/TEST/lib/smarty/Smarty.class.php on line 1088
Any ideas?
-
miss_d_bus
- Forum Members

- Posts: 121
- Joined: Sun May 01, 2005 4:27 pm
Re: apache rewrite file names
does anyone know?!
