Code Igniter site moved to new server - php

I hope all of you are having a great week!
I have moved a code ignite site to a new server, When I moved it across I tested it here.
http://31.25.190.77/~freelanc
Where it works perfectly, so then I pointed the domain name at it.
http://www.freelanceentrysolutions.co.uk/
but not it doesn't work! Only the homepage works but if I click another link I get
Not Found
The requested URL /supply-and-installations.html was not found on this
server.
Additionally, a 404 Not Found error was encountered while trying to
use an ErrorDocument to handle the request.
Any ideas here?
Kind Regards, Brad
SOLVED
I added this to the HTACCESS
RewriteEngine On
RewriteCond %{HTTP_HOST} ^freelanceentrysolutions\.co.uk$ [OR]
RewriteCond %{HTTP_HOST} ^www\.freelanceentrysolutions\.co.uk$
RewriteCond %{REQUEST_URI} !^/index.php/
RewriteRule (.*) /index.php/$1

It work perfectly with http://www.freelanceentrysolutions.co.uk/index.php/supply-and-installations.html !
i think the 'index.php/supply-and-installations.html' is problematic.

You might need to put index.php in all of your links?
/index.php/supply-and-installations.html
Try
http://www.freelanceentrysolutions.co.uk/index.php/supply-and-installations.html
or rewrite URLs to achieve this without using index.php
MODIFICATIONS:
If you are on apache put following in a .htaccess file and put that in root folder.
RewriteEngine on
RewriteCond $1 !^(index\.php|[Javascript / CSS / Image root Folder name(s)]|robots\.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]
Another good version is located here:
http://snipplr.com/view/5966/codeigniter-htaccess/

SOLVED! I added this to my HTAccess file.
RewriteEngine On
RewriteCond %{HTTP_HOST} ^freelanceentrysolutions\.co.uk$ [OR]
RewriteCond %{HTTP_HOST} ^www\.freelanceentrysolutions\.co.uk$
RewriteCond %{REQUEST_URI} !^/index.php/
RewriteRule (.*) /index.php/$1

Related

Rewrite Url at my website but my index on sub folder

I've been crawling forums for about 2 hours and still haven't found the solution to my problem so I am turning to you guys for help.
My URL looks like this
http://sevalinmutfagi.com/list.php?id=1?kategori=borekler
I want it to look like this
http://sevalinmutfagi.com/tarifler/borekler
I try so much rewrite example but my index file at a subfolder in /View/ so I can't rewrite my URLs
here my .htaccess
RewriteEngine on
RewriteCond %{HTTP_HOST} ^(www.)?sevalinmutfagi.com$ [NC]
RewriteCond %{REQUEST_URI} !^/View/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /View/$1 [L]
RewriteCond %{HTTP_HOST} ^(www.)?sevalinmutfagi.com$ [NC]
RewriteRule ^(/)?$ View/index.php [L]
This code works well for redirect subfolder all pages but I try to add rewrite URL codes can't work. I hope that has been revealing. Thanks to every for help.
that's worked for me fine.
RewriteEngine on
RewriteCond %{REQUEST_URI} !^/subfolder
RewriteRule ^(.*)$ /subfolder/$1 [NC,L]
The FIRST thing to learn about mod_rewrite is when NOT to use it. Since mod_alias handles your specific task very nicely, that’s what I’d use:
Redirect 301 / /subfolder/
Since that looks like it would be “loopy,” you could fall back on mod_rewrite:
RewriteEngine on
RewriteCond %{REQUEST_URI} !^subfolder/
RewriteRule .? subfolder%{REQUEST_URI} [R=301,L]
There’s just too much wrong with your attempt to cover … and I’ve addressed exactly those issues many times in many threads. Therefore, you might benefit from reading the mod_rewrite tutorial linked in my signature as it contains explanations and sample code. It’s helped may members and should help you, too

Using RewriteRule shows apache folder navigation or 404, why?

I have wordpress installed and in the root i created a folder and put an .htaccess inside to redirect to another web page without changing the URL.
This was working fine until i move to another server (the older one was just horrible) and now it just not working.
This is code that i was using:
RewriteEngine ON
RewriteCond %{REQUEST_URI} ^/conexionalam
RewriteRule ^(.*)$ http://nuevoserver.breinguash.com/$1 [R=301,L,P]
and is no longer working, show me this:
looking for internet i have tested some other codes:
1-
Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /
RewriteRule ^/conexionalam(/.*|)$ nuevoserver.breinguash.com$1 [L,NC]
2-
RewriteEngine ON
RewriteRule ^/(.+) http://nuevoserver.breinguash.com/$1 [R,L]
This two show me this:
3-
RewriteEngine ON
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ http://nuevoserver.breinguash.com/$1
This one redirect me to http://nuevoserver.breinguash.com/index.html
I realized that if i took off this '[R=301,L,P]' at the end of the first code, it works but changing the URL and i don't want tat.
Thanks in advanced!
EDIT:
By the moment im using this code:
RewriteEngine ON
RewriteCond %{REQUEST_URI} ^/conexionalam
RewriteRule ^(.*)$ http://nuevoserver.breinguash.com/$1
Its redirects but change the URL = /
but for now does not affect google analytics.
if i change or add something to the code it does show me the errors from above. i really doesn't understand why it does that.
SOLUTION
Well it seem that i cant redirect between domains/subdomains without changing the URL just like that, i have to do it with proxy, so the solution was:
Enable proxy and proxy-http on apache.
Use the P flag for RewriteRule
So right now i'm using this code and it works perfectly:
RewriteEngine ON
RewriteCond %{REQUEST_URI} ^/conexionalam
RewriteRule ^(.*)$ http://nuevoserver.breinguash.com/$1 [R=301,L,P]
Give this a shot in your .htaccess file...
RewriteEngine On
RewriteBase /
RewriteRule ^conexionalam(.*)$ http://nuevoserver.breinguash.com/$1 [L,R=301]
This should redirect you to http://nuevoserver.breinguash.com when you go to /conexionalam from your main domain.

.htaccess ReWriteRule - Requested URL <rewritten filename> was not found on this server

I've been testing this in WAMP and I can't get it to work. I believe WAMP is set up properly due to the error message I'm receiving and it works no problem when I don't use the .htaccess file.
I have a filename that I'm using for testing called Feedback.php. Instead of displaying as www.mysite.com/Feedback.php. I'm trying to get it to just be www.mysite.com/Feedback.
.htaccess file
RewriteEngine on
RewriteRule ^Feedback.php/?$ Feedback [NC]
The error message that I receive is
"Not FoundThe requested URL /Feedback was not found on this server."
Are there two files required for reWriteRule to work?
I'm also trying to get this to work for my index.php to just be www.mysite.com which may be a different monster.
What should my navbar links be? Right now they are Feedback Should href perhaps be href="Feedback" once I get this working?
EDIT: I had the ReWriteRule variables backwards. Instead of
RewriteRule ^Feedback.php/?$ Feedback [NC]
I should have
RewriteRule ^Feedback/$ /Feedback.php [NC,L]
The rewrite doesn't look to have taken place though as it still reads localhost/Feedback.php
You may use this to remove .php extension from your pages as well as omitting the index part to your website:
Options +FollowSymlinks
RewriteEngine On
RewriteCond %{THE_REQUEST} /index
RewriteRule ^index$ http://yourwebsite.com/ [R=301]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^(.*)$ $1.php [L]

Moving working CodeIgniter website to subfolder

I have a perfectly working website working as the root of my webhost (/public_html), but I recently bought a new domain and parked it there too, so I needed a subdir for it (/public_html/newdomaindir).
Now I need to move my entire website to a subfolder (/public_html/website) and I'm having a hard time adapting the .htaccess files.
This was my old working .htaccess file when it was root:
RewriteEngine on
RewriteCond %{HTTP_HOST} ^website.org$
RewriteRule ^/?$ "http\:\/\/www\.website\.org\/" [R=301,L]
#SetEnvIfNoCase Host ^www\.website\.org$ require_auth=true
RewriteCond $1 !^(index\.php|images|css|robots\.txt|js|icons|files|fonts|extplorer)
RewriteRule ^(.+)$ /index.php?/$1[L,QSA]
And now the webhost support suggest that I have this .htaccess file as root, to redirect traffic.
RewriteEngine On
Options +FollowSymlinks
RewriteCond %{HTTP_HOST} website.org$
RewriteCond %{REQUEST_URI} !website/
RewriteRule ^(.*)$ website/$1
But, well... it's not working as expected. My website is broken.
Should I use a different approach, maybe ask the support guys to change the document_root of my website? Should I change anything in the subfolder .htaccess file?
Any help is greatly appreciated. Thanks.
Not my strongest skill, but I would try to modify your previous .htaccess to following form:
RewriteEngine on
RewriteCond %{HTTP_HOST} ^website.org$
RewriteRule ^/?$ "http\:\/\/www\.website\.org\/" [R=301,L]
# not sure what about this
#RewriteCond $1 !^website\/(index\.php|images|css|robots\.txt|js|icons|files|fonts|extplorer)
RewriteRule ^$ website/ [L]
RewriteRule ^(.+)$ website/index.php?/$1[L,QSA]
If this does not work, maybe you will find some clues in this SO answer.

.htaccess - Redirect subdomain to folder

This question has probably been asked for over a thousand times, but I've tried so many scripts, and googled so long while finding nothing, I thought, let's just ask.
I simply want m.daltonempire.nl to be redirected to daltonempire.nl/m/ without the user seeing the URL change.
So if m.daltonempire.nl/hello.php is requested, I want the user to keep seeing this URL, while the page given is actually daltonempire.nl/m/hello.php.
Note: I do not want www., so simply http://m.daltonempire.nl
Thanks in advance,
Isaiah v. Hunen
Add this to your .htaccess in your web root / directory
RewriteEngine on
RewriteBase /
RewriteCond %{HTTP_HOST} ^m\.daltonempire\.nl$ [NC]
RewriteCond %{REQUEST_URI} !^/m(/|$) [NC]
RewriteCond %{REQUEST_FILENAME} !-d # not a dir
RewriteCond %{REQUEST_FILENAME} !-f # not a file
RewriteRule ^(.*)$ m/$1 [L]
The %{REQUEST_FILENAME} conditions would let you access /exists.php and not rewrite it to /m/exists.php. Remove those two if you want to rewrite even if that may potentially override existing files and directories.
Try this example:
RewriteCond %{HTTP_HOST} ^([^/.]+)\.example\.com$
RewriteCond %1 !^(www|ftp|mail)$ [NC]
RewriteRule (.+)$ "http://example.com/%1" [L,P]
Any requests http://test.example.com will be mapped to http://example.com/test/...
Try googling dynamic subdomain with php and htaccess to get better search results.
I have set CNAME of my sub domain below:
blog.mydomain.com
to my wordpress that installed in folder /blog/ under root directory.
Formerly I need to use this url to call wordpress:
http://blog.mydomain.com/blog/
which is ugly. I have tried many code to redirect:
http://blog.mydomain.com/
to the folder so I can use it as my wordpress url.
Finally I got .htaccess setting that is work:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^blog\.mydomain\.com$
RewriteCond %{REQUEST_URI} !^/blog/
RewriteRule (.*) /blog/$1
I have also CNAME other subdomain: http://forum.mydomain.com to mybb installation in folder /forum/mybb/ so the .htaccess need to put [L] on each of RewriteRule code as below.
RewriteEngine On
RewriteCond %{HTTP_HOST} ^forum\.tophyips\.info$
RewriteCond %{REQUEST_URI} !^/forum/mybb/
RewriteRule (.*) /forum/mybb/$1 [L]
RewriteCond %{HTTP_HOST} ^blog\.tophyips\.info$
RewriteCond %{REQUEST_URI} !^/blog/
RewriteRule (.*) /blog/$1 [L]
In case you want to use the code please don't forget to set the site url and cookie path in the application config file follow to the setting to make the redirection work properly.

Categories